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? Quote Link to comment 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); } ?> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.