Jump to content

[SOLVED] WHILE error


onthespot

Recommended Posts

Can anyone see the problem here...

 

$name=mysql_real_escape_string($_GET['comp']);
$res=mysql_query("SELECT * FROM leaguecomments WHERE comp_name = '$name' ORDER BY date DESC");

while($row=mysql_fetch_assoc($res)){

$user=$row['user'];
$comment=$row['comment'];
$commentdate=$row['date'];
           
$date=strtotime($commentdate);
$final_date=date("g:i a", $date);  
$final_date2=date("F j Y", $date);

 

mysql_fetch_assoc(): supplied argument is not a valid MySQL

 

I can't work it out?

Link to comment
https://forums.phpfreaks.com/topic/168821-solved-while-error/
Share on other sites

Can anyone see the problem here...

 

$name=mysql_real_escape_string($_GET['comp']);
$res=mysql_query("SELECT * FROM leaguecomments WHERE comp_name = '$name' ORDER BY date DESC");

while($row=mysql_fetch_assoc($res)){

$user=$row['user'];
$comment=$row['comment'];
$commentdate=$row['date'];
           
$date=strtotime($commentdate);
$final_date=date("g:i a", $date);  
$final_date2=date("F j Y", $date);

 

mysql_fetch_assoc(): supplied argument is not a valid MySQL

 

I can't work it out?

might be your query returned 0 record, you should check whether there are any records or not and if there are records then use loop to display.

Link to comment
https://forums.phpfreaks.com/topic/168821-solved-while-error/#findComment-890706
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.