ivytony Posted February 22, 2008 Share Posted February 22, 2008 I think this is a more PHP question than MysQL. If the moderator thinks I am wrong, you are welcome to move the topic to mysql board. I have the following code $domain = 'cnn.com'; $sql = "SELECT id FROM table_news WHERE domain = '$domain'"; //id is the primary key, auto-incrmented $row = $db->query($sql); echo $row['id']; //the domain cnn.com in the table corresponds to the ID 10, but this echo gives me 1, I don't know where I made it wrong. someone can help me out? thanks! Link to comment https://forums.phpfreaks.com/topic/92524-weird-result-when-retrieving-id-from-mysql/ Share on other sites More sharing options...
BlueSkyIS Posted February 22, 2008 Share Posted February 22, 2008 $ID holds the result of the query function. you still need to pull a row from the result set $ID. Link to comment https://forums.phpfreaks.com/topic/92524-weird-result-when-retrieving-id-from-mysql/#findComment-474106 Share on other sites More sharing options...
ivytony Posted February 22, 2008 Author Share Posted February 22, 2008 thanks, I corrected my code, but it still shows 1, not 10. I am wondering why. Link to comment https://forums.phpfreaks.com/topic/92524-weird-result-when-retrieving-id-from-mysql/#findComment-474108 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.