Beeeeney Posted October 9, 2012 Share Posted October 9, 2012 (edited) 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. Edited October 9, 2012 by Beeeeney Quote 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']; } Quote 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. Quote Link to comment https://forums.phpfreaks.com/topic/269251-resource-id/#findComment-1383908 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.