Shadow Hatake Posted March 20, 2006 Share Posted March 20, 2006 [code] <?phpinclude('dbconnect.php');$id = $_GET['jid'];$question = $_GET['q'];if( isset( $_GET['jid'] ) ) { if( isset( $_GET['q'] ) ) { $query = 'SELECT '.$question.' FROM boards WHERE id = "'.$id.'"'; $result = mysql_query( $query ); if( $result ) { echo $result; } else { echo 'Error'; } } else { echo 'Page accessed incorrectly...'; }} else { echo 'Page accessed incorrectly...';}?>[/code]All I'm getting is resource id #3 when it should be showing the query. Help? Link to comment https://forums.phpfreaks.com/topic/5319-query-returns-resource-id-3/ Share on other sites More sharing options...
hitman6003 Posted March 20, 2006 Share Posted March 20, 2006 Change:[code]echo $result;[/code]to:[code]echo "<table>";while ($row = mysql_fetch_array($result)) { echo "<tr>"; foreach ($row as $key => $value) { echo "<td>$key</td><td>$value</td>"; } echo "<tr>";}echo "</table>";[/code]when you assign $result to mysql_query("some sql") it creates a reference to the object that contains your data. You have to use other php mysql functions to access the data contained inside. Link to comment https://forums.phpfreaks.com/topic/5319-query-returns-resource-id-3/#findComment-18944 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.