Jump to content

while (fetch_array() error)


otuatail

Recommended Posts

Hi I am trying to update a table The query works for retreving a single row but when in a loop it fails.

 

This works
$sql = "SELECT * FROM EventLog where EventID = 3069";
$query = mysql_query($sql) or die(mysql_error());
$rs = mysql_fetch_array($query);
echo $rs['EventID'];

 

This dosnt

?php
session_start();
include ("functions.php");
connectDB(1);
$sql = "SELECT * FROM EventLog where EventID > 3069";
$query = mysql_query($sql) or die(mysql_error());
//$rs = mysql_fetch_array($query);
//echo $rs['EventID'];

while ($row = mysql_fetch_array($query)) // Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

{
  $event = $row['EventID'];
  $date = date('Y-m-d H:i:s' , $row['Stamp']);
// ****** //
$sql2 = "UPDATE EventLog SET Date = '$date' WHERE EventID = $event";
$query = mysql_query ($sql2);
}

?>

 

Can't see the problem

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

Can't see the problem. I have used this before

$sql = "SELECT * FROM EventLog where EventID > 3069";
$query = mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($query)) // Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
{

}

 

 

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.