Alicia Posted May 17, 2006 Share Posted May 17, 2006 Hi, Can somebody give me an idea why nothing is displayed when i try to output the last login and ip value by using this code : [code]$check1 = mysql_query("SELECT * FROM `log` WHERE `username`='$username'") or die(mysql_error()); $row_check1 = mysql_fetch_row($check1); $last_login = $row_check1['latest_login']; $last_login_ip = $row_check1['lastest_login_ip']; echo "< $last_login | $last_login_ip >";// nothing is displayed ... the variables name are used correctly [/code]please advise. Quote Link to comment Share on other sites More sharing options...
alpine Posted May 17, 2006 Share Posted May 17, 2006 assuming you have $username set previously in your code, try mysql_fetch_array() instead of mysql_fetch_row()[code]// $row_check1 = mysql_fetch_row($check1);$row_check1 = mysql_fetch_array($check1);[/code] Quote Link to comment Share on other sites More sharing options...
toplay Posted May 17, 2006 Share Posted May 17, 2006 Good point Alpine. However, I would go a step further and say use mysql_fetch_assoc() which returns an associated array (which is all you're using).You should also check after the fetch if any data was returned. Don't assume it did. The query might not give any errors and the fetch returns no data. This is not an error or problem but simply that it means there was no data that met the search criteria.FYI:Click on the [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=31047&view=findpost&p=153359\" target=\"_blank\"]PHP F.A.Q.[/a] link. Find and read the [b]MySQL Data Retrieval[/b] section for example code of getting data from MySQL with error checking after every MySQL command. 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.