我尝试上传图片时出错(php)

时间:2014-02-25 11:20:07

标签: php html parse-error

每次尝试使用upload.php时都会出现此错误。 (我想为文件名是用户名的图像制作一个上传文件)

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>

以下是我如何使用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>

1 个答案:

答案 0 :(得分:1)

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

需要

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