简体   繁体   中英

Error in fetching rows from table using SQL

This code was working fine yesterday , and suddenly started showing error today.. The die('Error') gives out error when displaying the users with profile pictures Thanks in advance for the help ... i am learning php so will convert to pdo later

<?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);
?>

Link to the db https://www.dropbox.com/s/dv8vhla0fxhw2p7/db.png

I think you mis-typed adno for idno in your select query.

Hope that helps

SELECT adno,

改成

SELECT idno,

delete extra ; from query

$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');;

to

$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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM