Jump to content


Photo

Query returns resource id #3


  • Please log in to reply
1 reply to this topic

#1 Shadow Hatake

Shadow Hatake
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 20 March 2006 - 01:48 AM

<?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...';
}

?>

All I'm getting is resource id #3 when it should be showing the query. Help?

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 20 March 2006 - 02:01 AM

Change:

echo $result;

to:

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>";

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users