Navajo Posted February 25, 2009 Share Posted February 25, 2009 When I'm returning to the screen I'm getting resorce ID 5 instead of the value I want from the datdabase? My code: $getDes = mysql_query("SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'"); echo "$getDes"; I'm clearly being a bit thick Link to comment https://forums.phpfreaks.com/topic/146837-solved-resorce-id-instead-of-data-from-database/ Share on other sites More sharing options...
trq Posted February 25, 2009 Share Posted February 25, 2009 mysql_query returns a result resource, you'll want to pass it to mysql_fetch_assoc to get the actual data. Link to comment https://forums.phpfreaks.com/topic/146837-solved-resorce-id-instead-of-data-from-database/#findComment-770895 Share on other sites More sharing options...
Navajo Posted February 25, 2009 Author Share Posted February 25, 2009 Ok so I'm trying: $getDes = mysql_query("SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'"); $row = mysql_fetch_assoc($getDes); echo "$row"; This returns the word Array, instead of ResorceID5, what am I doing wrong? Link to comment https://forums.phpfreaks.com/topic/146837-solved-resorce-id-instead-of-data-from-database/#findComment-770899 Share on other sites More sharing options...
trq Posted February 25, 2009 Share Posted February 25, 2009 mysql_fetch_assoc returns an array. Your code should read.... <?php $sql = "SELECT vchar_description FROM pctest WHERE vchar_product_id = '$productIDCode'"; if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { $row = mysql_fetch_assoc($getDes); echo $row['vchar_description']; } } ?> ps: Theres a link to a free book (hudzilla) that should get you started, this is pretty basic stuff. Link to comment https://forums.phpfreaks.com/topic/146837-solved-resorce-id-instead-of-data-from-database/#findComment-770902 Share on other sites More sharing options...
Navajo Posted February 25, 2009 Author Share Posted February 25, 2009 Thanks I'll give it a read. Link to comment https://forums.phpfreaks.com/topic/146837-solved-resorce-id-instead-of-data-from-database/#findComment-770903 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.