您好,我有一个网站,可以向用户显示他们自己的个人资料图片。但我无法这样做,我已经构建了一个代码,但它无法正常工作并给出错误,Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/u522159750/public_html/users/myaccount.php on line 156
即$sql = mysqli_query($link, "SELECT id, name, avatar FROM users WHERE id="'.$id.'" ") ;
任何人都可以建议我可能是什么原因。显示图像的代码如下---
<p>
<?php
//We check if the users ID is defined
$db_host = "xxxxxxxxxxxx";
$db_username = "xxxxxxxxxxxxxx";
$db_password = "xxxxxxxxx";
$db_database = "xxxxxxxxxxxxxx";
$link = mysqli_connect($db_host,$db_username,$db_password) or die("Cannot connect");
mysqli_select_db($link, $db_database) or die("Cannot select the database");
$sql = mysqli_query($link, "SELECT id, name, avatar FROM users WHERE id="'.$id.'" ") ;
while($result = mysqli_fetch_object($sql)):
<a href="http://www.mysite.tk/users/myaccount.php"> <img src="<?php echo $result->avatar; ?>" alt="<?php echo $result->name; ?>" width="200" height="300" /></a>
?> </p>
<?php endwhile; ?>