Page 1 of 1

Blog Tutorial mysql_fetch_assoc() Error

Posted: Tue May 24, 2011 10:12 pm
by Silkenthread
Hi

Ref:http://www.youtube.com/user/betterphp#p ... jcZ1_kO_tA

blog tutorial

I did got this working by putting an ( if statment in but it will not work now so I took it out ) and its still giving me the same problem as I first had. error:-

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in ---posts.inc.php on line 41

Any ideas what I can do to resolve this thanks.

I have this as lines 38 - 42
$posts = mysql_query($sql);

$rows = array();
while (($row = mysql_fetch_assoc($posts)) !== false){
$rows[] = array(
Hope you can help.

Re: mysql_fetch_assoc()

Posted: Tue May 24, 2011 10:39 pm
by Tino
Your query is failing. Add echo mysql_error() after your query ;)

Re: mysql_fetch_assoc()

Posted: Tue May 24, 2011 11:35 pm
by jacek
Please use the php button when posting code on the forum. Also do what Tino said ;)

Re: Blog Tutorial mysql_fetch_assoc() Error

Posted: Thu May 26, 2011 6:00 pm
by Silkenthread
I have tried but still no good I will recheck the code against the tutorials and see what the problem is. Thanks for your help though.

Re: Blog Tutorial mysql_fetch_assoc() Error

Posted: Thu May 26, 2011 6:04 pm
by jacek
Silkenthread wrote:I have tried but still no good I will recheck the code against the tutorials and see what the problem is. Thanks for your help though.
if you added
echo mysql_error();
after this line
$posts = mysql_query($sql);
you should have got a description of the problem ...