I have following code..
$query = "SELECT quote, author FROM quotes ORDER BY id DESC";
$resut = mysql_query($query, $connection) or die(mysql_error());
echo $result; //for debuggin purpose
while($result_set = mysql_fetch_array($result)) {
echo '<div class="pullquote">';
echo $result_set['quote'];
echo ' - ';
echo $result_set['author'];
echo '</div>';
}
and this doesn't works! The table is not empty FYI, all I see in the output is:
Resource id #9
I am not being able to figure out what this Resource id #9
means. As I tested SELECT quote, author FROM quotes ORDER BY id DESC
in phpmyadmin, that just works fine and produces desired result, but not in here. I wonder what is wrong with the code or something?
If I do following,
$array = mysql_fetch_assoc($result);
var_dump ($array);
It returns, bool(false)
. What does that mean here?
There's nothing wrong with Resource id #9
(this just means you have a resource). Note the documentation on this topic:
For
SELECT
,SHOW
,DESCRIBE
,EXPLAIN
and other statements returningresultset
,mysql_query()
returns aresource
on success, orFALSE
on error.
So if you have "Resource," it means your query didn't fail.
Additionally, you are setting $resut
, and attempting to access $result
. Note the missing "l".