MySQL Forums
Forum List  »  PHP

Re: Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
Posted by: Adrian Danciu
Date: June 16, 2009 01:05PM

Thanks PB, but it is still not working.


I wrote this code, but I get an error at the line "call mysql_error()". Error is: Parse error: syntax error, unexpected T_STRING in /home/...:

<?php
if( $result = mysql_query("select * from $tablenews where id_news = '".$id."'")) {
if( mysql_num_rows( $result ))
$ress=mysql_fetch_assoc($result);

?>
<? if ($ress['title_news'] != '') { ?><h1><?=$ress['title_news']?></h1><BR><? } ?>
<? if ($ress['text_news'] != '') { ?><?=$ress['text_news']?><BR><? } ?>

<?php
}
else {
?>
<? if ($ress['title_news'] != '') { ?><h1><?=$ress['title_news']?></h1><BR><? } ?>
<? if ($ress['text_news'] != '') { ?><?=$ress['text_news']?><BR><? } ?>
<?php
call mysql_error()
}

?>

What did I do wrong? Sorry, but I am kindda new to this. Could you kindly write the entire correct code?
If I remove the entire else {...} part, I don't get the error anymore, but no data on the page, either

Many thanks

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.