wwedude Posted September 7, 2008 Share Posted September 7, 2008 I have the following in my site: $lastVisit = mysql_fetch_array(mysql_query("SELECT column FROM table WHERE username = '$username'")); But, when I echo the $lastVisit it comes up as "Array" when it should be "06", is there a problem in this code? Link to comment https://forums.phpfreaks.com/topic/123166-error/ Share on other sites More sharing options...
cooldude832 Posted September 7, 2008 Share Posted September 7, 2008 yes a lot of things 1) Don't nest it into 1 decleration 2) You didn't error check 3) It is an array of all results in your series better <?php $q = "SELECT column FROM table WHERE username = '$username'"; $r = mysql_query($q) or die(mysql_error()); if(mysql_num_rows($r) >0){ $row = mysql_fetch_assoc($r); print_r($row); } ?> Link to comment https://forums.phpfreaks.com/topic/123166-error/#findComment-636106 Share on other sites More sharing options...
snk Posted September 8, 2008 Share Posted September 8, 2008 or echo $lastVisit[0]; if you are 100% that there is just one entry. Link to comment https://forums.phpfreaks.com/topic/123166-error/#findComment-636396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.