Hi there, I need some help with this error/warning
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource

here is the code:

include "connect.php";
include "comment.class.php";

$result = mysql_query("select * from comments order by id");
$comments = array();

while($row = mysql_fetch_assoc($result))
{
	$comments[] = new Comment($row);
}
?>

i connected the database it is named comments and had a column id. cant think what's the problem with my code. at connect.php I set the connection for the mysqldatabase. can you point out what's the problem here? thanks

'var_dump($result)' before while loop. Check which '$result' has, it should be mysql resources. If not 'mysql_fetch_assoc()' will returns the error. Check with 'var_dump()' first.

Member Avatar for P0lT10n

Your error is that you done an ORDER BY with out the parameter DESC or ASC ...

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.