Blog Tutorial mysql_fetch_assoc() Error

Post here is you are having problems with any of the tutorials.
Post Reply
Silkenthread
Posts: 6
Joined: Tue May 24, 2011 5:33 pm

Blog Tutorial mysql_fetch_assoc() Error

Post 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.
Tino
Posts: 360
Joined: Thu May 05, 2011 8:55 pm
Location: The Netherlands

Re: mysql_fetch_assoc()

Post by Tino »

Your query is failing. Add echo mysql_error() after your query ;)
Please check out my CodeCanyon items.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: mysql_fetch_assoc()

Post by jacek »

Please use the php button when posting code on the forum. Also do what Tino said ;)
Image
Silkenthread
Posts: 6
Joined: Tue May 24, 2011 5:33 pm

Re: Blog Tutorial mysql_fetch_assoc() Error

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

Re: Blog Tutorial mysql_fetch_assoc() Error

Post 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 ...
Image
Post Reply