Question

I get this error everytime I try to use upload.php. (I want to make an uplaod for an image where the filename is the username)

Parse error: syntax error, unexpected 'width' (T_STRING), expecting ',' or ';' in 
D:[...]\upload.php on line 24

upload.php:

<?php

include('auth.php'); 
include 'dbconnection.php';

$user= "1";

$id=($_SESSION['logedin']);
$abfrage = "SELECT * FROM login WHERE id = '$id'";
$ergebnis = mysql_query($abfrage);
while($row = mysql_fetch_object($ergebnis))
   {
       $user= (".$row->id.") ;
   }

 move_uploaded_file($_FILES['image']['tmp_name'], './images/'.$user.'jpg');
?>
<!DOCTYPE html>
<html>
  <head></head>
  <body>

 <?php
 echo "<img style="width: 250px; height: 500px" src="'./images/'.$user.'jpg''?v='.rand(0,1000)"/>" 
 ?>

  </body>
</html>

Here is how I use upload.php:

<form method="post" action="upload.php" enctype="multipart/form-data" target="leiframe">
      <input type="file" name="image"/>
      <input type="submit" value="upload"/>
</form>
Was it helpful?

Solution

echo "<img style="width: 250px; height: 500px" src="'./images/'.$user.'jpg''?v='.rand(0,1000)"/>"

needs to be

echo '<img style="width: 250px; height: 500px" src="./images/'.$user.'jpg?v='.rand(0,1000).'"/>';

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top