Jump to content

whats wrong with my code ?


Alicia

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/9833-whats-wrong-with-my-code/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.