jtjtjthey Posted July 25, 2008 Share Posted July 25, 2008 Hi all! I've seen my codes and it looks ok for me but when i execute the code it shows Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\Program Files\xampp\htdocs\notification_system\user\user.php on line 117 Here is the code: <? // display the record when assignation ends < current date $time2=date('Y-m-d H:i:s'); $sql2="SELECT * FROM directory WHERE assignation_ends < $time2"; $result2=mysql_query($sql2); ?> <form name="user_main_page" method= "post" action= "save.php"> <table width="786" border="1" align="center"> while ($fetch_result=mysql_fetch_array($result2)) { $time2=date('Y-m-d H:i:s'); $assignation_ends=$fetch_result['assignation_ends']; if($result2) { <tr> <td align= "center" >[/color]<span class="style4"><? echo $fetch_result['id']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['name']; ?> </span> </td> <td align="center"> <span class="style4"> <? echo $fetch_result['department']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['position']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['assignation_starts']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['assignation_ends']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['email']; ?> </span> </td> <td align= "center" > <span class="style4"> <? echo $fetch_result['status']; ?> </span> </td> <td align= "center" > <span class="style4"> <a href="<? echo "save.php?id=" .$fetch_result['id']. "&mode=update"?>">Comment</a> </span> </td> </tr> <? } } ?> </table></form> Does anybody have a idea on this? Link to comment https://forums.phpfreaks.com/topic/116530-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
DarkWater Posted July 25, 2008 Share Posted July 25, 2008 If I ever see that many colors used in a single post ever again, I'm going to completely ignore the thread. Just throwing that out there. Anyway, add "or die(mysql_error());" without the quotes, obviously, after your mysql_query() call. It'll look like: mysql_query($sql) or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/116530-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-599182 Share on other sites More sharing options...
vikramjeet.singla Posted July 25, 2008 Share Posted July 25, 2008 i think your query in properly created. it should be: $sql2="SELECT * FROM directory WHERE assignation_ends < '".$time2."'"; instead of: $sql2="SELECT * FROM directory WHERE assignation_ends < $time2"; Link to comment https://forums.phpfreaks.com/topic/116530-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-599187 Share on other sites More sharing options...
jtjtjthey Posted July 25, 2008 Author Share Posted July 25, 2008 i think your query in properly created. it should be: $sql2="SELECT * FROM directory WHERE assignation_ends < '".$time2."'"; instead of: $sql2="SELECT * FROM directory WHERE assignation_ends < $time2"; Thanks vikramjeet for the solution. I've made it! Link to comment https://forums.phpfreaks.com/topic/116530-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-599204 Share on other sites More sharing options...
jtjtjthey Posted July 25, 2008 Author Share Posted July 25, 2008 If I ever see that many colors used in a single post ever again, I'm going to completely ignore the thread. Just throwing that out there. Anyway, add "or die(mysql_error());" without the quotes, obviously, after your mysql_query() call. It'll look like: mysql_query($sql) or die(mysql_error()); Sorry about the mess. I thought it would be easier for you to read the code. Link to comment https://forums.phpfreaks.com/topic/116530-mysql_fetch_array-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-599208 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.