使用SQL从表中获取行时出错

时间:2013-11-09 10:47:31

标签: php mysql sql

这段代码昨天工作正常,今天突然开始显示错误.. 当显示具有个人资料图片的用户时,模具('错误')会发出错误 在此先感谢您的帮助......我正在学习php,以便稍后转换为pdo

<?php
include("dbconfig.php");
// Create connection
$conn=mysql_connect($db_host,$username,$password) or die('Error1');;

mysql_select_db("motorklq_glmindb",$conn) or die('Error2');


$result = mysql_query("SELECT adno,fname,lname,profilepic,gscore FROM gtable WHERE contest!='on' ORDER BY gscore DESC  LIMIT 3") or die('Error');;

echo "<table><tr><th></th><th>gScore Leader</th><th></th><th></th></tr>";
echo "<tr><th>Firstname</th><th>Lastname</th><th>Image</th><th>Glamour</th></tr>";

while($row = mysql_fetch_array($result)){
    print "<tr><td>".$row['fname']."</td><td>".$row['lname']."</td><td>".'<img src="data:image/jpeg;base64,' . base64_encode( $row['profilepic'] ) . '"  width="32" height="32">'."</td><td>".$row['gscore']."</td></tr>";
}
print "</table>";
mysql_close($conn);
?>

链接到数据库https://www.dropbox.com/s/dv8vhla0fxhw2p7/db.png

3 个答案:

答案 0 :(得分:0)

我认为您在选择查询中错误输入了 adno idno

希望有所帮助

答案 1 :(得分:0)

SELECT adno,

更改为

SELECT idno,

答案 2 :(得分:0)

删除额外;来自查询

$conn=mysql_connect($db_host,$username,$password) or die('Error1');;
$result = mysql_query("SELECT adno,fname,lname,profilepic,gscore FROM gtable WHERE contest!='on' ORDER BY gscore DESC  LIMIT 3") or die('Error');;

$conn=mysql_connect($db_host,$username,$password) or die('Error1');
$result = mysql_query("SELECT idno,fname,lname,profilepic,gscore FROM gtable WHERE contest!='on' ORDER BY gscore DESC  LIMIT 3") or die('Error');