Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/mandarin/public_html/wyandotte/includes/flash_functions/events.php on line 7

I have no idea how to fix this. Here is the code I use

<?php
//calls on the database to display the results of my Events query.  This will show us what's happening lately
require(DIR_INCLUDES . 'app_top.php');

$qresult = mysql_query ("SELECT * FROM events ORDER BY event_id DESC");

$nrows = mysql_num_rows($qresult);
$rstring ="&n=".$nrows;


for ($i=0; $i< $nrows; $i++){
    $row = mysql_fetch_array($qresult);
    $rstring .="&id".$i."=".$row['event_id']."&"."&title".$i."=".$row['event_title']."&"."&date".$i."=".$row['event_date']."&"."&entry".$i."=".$row['event_post']."&";
}
echo $rstring."&";

?>

my app_top file is simple enough, it calls the config file for connection to the database. What am I doing wrong?

You could use the COUNT function that exists in MySQL instead.

$count = mysql_query ("SELECT COUNT(*) AS count FROM events ORDER BY event_id DESC");

$count = $count['count'];

// $count now contains # of rows
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.