I'm trying to update some records in my database via php. This is the part of my code that returns error:
<?php
//turn on error reporting
ini_set('display_errors',1);
error_reporting(E_ALL);
// Check if button name "Submit" is active, do this
if(isset($_POST['Submit']))
{
$count=mysql_num_rows($result);
for($i=0;$i<$count;$i++)
{
if(isset($title[$i],$descr[$i],$price[$i],$cname[$i],$pid[$i]))
{
$query = "
UPDATE products
SET title='$title[$i]',
descr='$descr[$i]',
price='$price[$i]',
cname='$cname[$i]'
WHERE pid='$pid[$i]'
";
$upd = mysql_query($query) or die(mysql_error());
}
else
{
$upd = FALSE;
echo "One of the variables isn't set.\n<br/>";
}
}
if($upd)
{
echo "Successful";
echo "<BR>";
//display_manager_menu();
}
else {
echo "Something wrong";
}
}
mysql_close();
?>
It returns: "Notice: Undefined variable: upd ". Since I set $upd
as mysql_query result, I have no idea why I get this message. Any ideas?