Beeeeney Posted October 9, 2012 Share Posted October 9, 2012 Hi all. I'm a complete nub at PHP so I was wondering if anyone could help me out? This code: <?php mysql_connect("localhost", "XXX", "XXX") || die('Error:' . mysql_error()); mysql_select_db("newsite"); $query = "SELECT * FROM `newsite` . `content`"; $post = mysql_query($query); echo $post; ?> Returns "resource id #4" to the browser. Any ideas on how to get it to return the actual DB data? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/269251-resource-id/ Share on other sites More sharing options...
TOA Posted October 9, 2012 Share Posted October 9, 2012 mysql_query returns a resource ID you use with any of the fetch_ functions. So use fetch_result or fetch_row or something similar. For example $post = $mysql_query($sql); while ($row = mysql_fetch_row($post)) { echo $row['somvalue']; } Link to comment https://forums.phpfreaks.com/topic/269251-resource-id/#findComment-1383899 Share on other sites More sharing options...
Beeeeney Posted October 9, 2012 Author Share Posted October 9, 2012 It worked, thanks. Link to comment https://forums.phpfreaks.com/topic/269251-resource-id/#findComment-1383908 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.