forumnz Posted December 24, 2007 Share Posted December 24, 2007 What have I done wrong? It should be simple. Code: <?php $uid = $row['uid'] ; echo $uid; $con = mysql_connect("localhost","aaa","aaa"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("aaa", $con); $result = mysql_query("SELECT * FROM currentclients WHERE 'id'=$uid"); while($row = mysql_fetch_array($result)) { $fname = $row['fname'] ; $lname = $row['lname'] ; $url = $row['url'] ; $email = $row['email'] ; $address = $row['address'] ; $phone = $row['phone'] ; $active = $row['receive'] ; } echo $fname; mysql_close($con); ?> Error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /usr/local/www/vhosts/aaa.com/httpdocs/clientemail/edit.php on line 22 Thanks, Sam. Link to comment https://forums.phpfreaks.com/topic/83059-select-problem/ Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 Change WHERE 'id'=$uid"); to WHERE id='$uid'"); Link to comment https://forums.phpfreaks.com/topic/83059-select-problem/#findComment-422488 Share on other sites More sharing options...
revraz Posted December 24, 2007 Share Posted December 24, 2007 Also, to avoid this error, you should check the number of rows returned before you put the results in an array, since there is no point to the array if the results are empty. Link to comment https://forums.phpfreaks.com/topic/83059-select-problem/#findComment-422491 Share on other sites More sharing options...
PFMaBiSmAd Posted December 24, 2007 Share Posted December 24, 2007 A result set with zero rows does NOT generate that error message. Only a query that failed (syntax error, no connection to database server, no database selected...) does. Link to comment https://forums.phpfreaks.com/topic/83059-select-problem/#findComment-422506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.