Jump to content

Recommended Posts

[code] <?php

include('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

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.