Jump to content

mysql_fetch_array(): supplied argument is not a valid MySQL result resource


jtjtjthey

Recommended Posts

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?

 

     

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());

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";

 

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! ;D

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.  ::)

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.