lalu Posted September 6, 2006 Share Posted September 6, 2006 I got error like this:============================Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/web/public_html/agenda2.php on line 15Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/web/public_html/agenda2.php on line 64 ===================this my code:==================[code]<?phpinclude("inc/header_dalam.php");if(!isset($asu)){ $asu=array(); session_register("asu");}if(!in_array($idagenda,$asu)){ //echo count($asu)."--"; array_push($asu,$idagenda); $sql_update="Select counter from tbagenda where idAgenda=".$idagenda; $res_update=mysql_query($sql_update); $row_update=mysql_fetch_assoc($res_update); $counter_x=$row_update[counter]+1; $sql_update2="Update tbagenda set counter=$counter_x where idAgenda=".$idagenda; $res_update2=mysql_query($sql_update2);}?> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="9"> </td> <td><img src="images/spacer.gif" width="1" height="10"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="317"> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td width="9"> </td> <td> <? echo ' <span class="judul">'; echo $judul_agenda; echo '</span>'; ?> </td> <td width="12"> </td> </tr> </table> </td> <td width="99" height="31"> </td> </tr> </table></td> </tr> <tr> <td class="contentdalam" valign="top" height="350"> <br> <table border=0 cellspacing=0 cellpadding=0 width=100%> <tr> <td><a href="agenda.php?ver=<?=$ver?>" class="iber">INDEX <?=$judul_agenda?></a></td> </tr> </table> <br> <!-- startprint --> <table border=0 cellspacing=0 cellpadding=2 width=100%> <? $sqlview = "SELECT * from tbagenda where idAgenda=".$idagenda; $resagenda1 = mysql_query($sqlview); while ($rowagenda1 = mysql_fetch_array($resagenda1)) { echo '<center><strong>'.$rowagenda1[namaAgenda.$bahasa].'</strong><br>'; if($rowagenda1[mulaiAgenda]==$rowagenda1[selesaiAgenda]) { if($bahasa=="_e") { echo date("d M Y", $rowagenda1[mulaiAgenda]).'<br>'; } else { echo TglIndo($rowagenda1[mulaiAgenda],"s"); } } else { if($bahasa=="_e") { echo date("d M Y", $rowagenda1[mulaiAgenda])." - ". date("d M Y", $rowagenda1[selesaiAgenda]).'<br>'; } else { echo TglIndo($rowagenda1[mulaiAgenda],"s")." - ". TglIndo($rowagenda1[selesaiAgenda],"s"); } } echo '<br><br></center>'; echo $rowagenda1[isiAgenda.$bahasa]; } echo '</table>'; ?> <!-- stopprint --> <p align="right"> <? echo '<b>Viewed: '.$viewx.'</b><br>'; echo '<A HREF="#" onClick="window.open(\'send_agenda.php?idagenda='.$idagenda.'&ver='.$ver.'\',\'Send\',\'width=500,height=350,resizable=yes\')">send to friend</a><br>'; ?> <a href="phprint.php">Print Version <img src="images/print.gif" border="0" align="absmiddle"></a> </p> </td> </tr> </table></td> <td width="20"> <td> </tr> </table></td> </tr> </table><?phpinclude("inc/footer_dalam.php");?>[/code]=================any help will appreciate:)thanks Quote Link to comment Share on other sites More sharing options...
Barand Posted September 6, 2006 Share Posted September 6, 2006 change line 14 to$res_update=mysql_query($sql_update) or die (mysql_error());That should help to locate the error. Do similar with other query.BTW: you could accomplish this[code] $sql_update="Select counter from tbagenda where idAgenda=".$idagenda; $res_update=mysql_query($sql_update); $row_update=mysql_fetch_assoc($res_update); $counter_x=$row_update[counter]+1; $sql_update2="Update tbagenda set counter=$counter_x where idAgenda=".$idagenda; $res_update2=mysql_query($sql_update2);[/code]with[code]mysql_query ("UPDATE tbagenda SET counter=counter+1 WHERE idAgenda = '$idagenda' ");[/code] Quote Link to comment Share on other sites More sharing options...
arianhojat Posted September 6, 2006 Share Posted September 6, 2006 maybe need to select correct database that tables are in before running that code like...$db = 'agendaDB';mysql_select_db($db) or die ("Unable to select database!"); Quote Link to comment Share on other sites More sharing options...
lalu Posted September 7, 2006 Author Share Posted September 7, 2006 [quote author=Barand link=topic=107079.msg429067#msg429067 date=1157536777]change line 14 to$res_update=mysql_query($sql_update) or die (mysql_error());That should help to locate the error. Do similar with other query.BTW: you could accomplish this[code] $sql_update="Select counter from tbagenda where idAgenda=".$idagenda; $res_update=mysql_query($sql_update); $row_update=mysql_fetch_assoc($res_update); $counter_x=$row_update[counter]+1; $sql_update2="Update tbagenda set counter=$counter_x where idAgenda=".$idagenda; $res_update2=mysql_query($sql_update2);[/code]with[code]mysql_query ("UPDATE tbagenda SET counter=counter+1 WHERE idAgenda = '$idagenda' ");[/code][/quote]Thank you very much Mr Moderator, but now I got an error like this[code]Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mmugmac/public_html/agenda2.php on line 65[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 Add the "..or die (mysql_eror()) to the other query$resagenda1 = mysql_query($sqlview) or die (mysql_eror()) ;Do you get any error messages when you have done that? Quote Link to comment Share on other sites More sharing options...
lalu Posted September 7, 2006 Author Share Posted September 7, 2006 [code]<? $sqlview = "SELECT * from tbagenda where idAgenda=".$idagenda; $resagenda1 = mysql_query($sqlview) or die (mysql_error()); while ($rowagenda1 = mysql_fetch_array($resagenda1)) {[/code]now i got error like this:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 7, 2006 Share Posted September 7, 2006 it might depend on the version of php you're running if mysql_fetch_assoc would worktry mysql_fetch_array($your_Query, MYSQL_ASSOC);what kind of field is idAgenda? you may need to close the sting out with a double quote. echo $sql_update and see if it is giving you what you expect$sql_update="Select counter from tbagenda where idAgenda=".$idagenda; Quote Link to comment Share on other sites More sharing options...
lalu Posted September 7, 2006 Author Share Posted September 7, 2006 [quote author=emehrkay link=topic=107079.msg429651#msg429651 date=1157591938]it might depend on the version of php you're running if mysql_fetch_assoc would worktry mysql_fetch_array($your_Query, MYSQL_ASSOC);what kind of field is idAgenda? you may need to close the sting out with a double quote. echo $sql_update and see if it is giving you what you expect$sql_update="Select counter from tbagenda where idAgenda=".$idagenda;[/quote]i have tried your help emehrkey but it doesn't work. Quote Link to comment Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 Make sure $idagenda actually fas a value in it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.