Jump to content

UPDATE not working


doddsey_65

Recommended Posts

Okay here is the code:

 

if (isset ($_COOKIE['ID_my_site'])) 
{ 
$username = mysql_real_escape_string($_COOKIE['ID_my_site']); 
$pass = mysql_real_escape_string($_COOKIE['Key_my_site']);
$check = mysql_query("SELECT * FROM users WHERE username = '{$username}'")or trigger_error (mysql_error()); 

if (mysql_num_rows ($check) > 0)
{
	$info = mysql_fetch_array ($check);

	//if the cookie has the wrong password, they are taken to the login page 
	if ($pass != $info['password'])
	{ header("Location: login.php"); }

	else
	{

$uploadDir = 'uploads/';

if(isset($_POST['upload']))
{
$fileName = $_FILES['userfile']['name'];
$tmpName = $_FILES['userfile']['tmp_name'];

$filePath = $uploadDir . $fileName;

$result = move_uploaded_file($tmpName, $filePath);
if (!$result) {
echo "Error uploading file";
exit;
}

if(!get_magic_quotes_gpc())
{
$filePath = addslashes($filePath);
} 

$query = ("UPDATE users SET path='$filePath' WHERE username='$username'");
echo $query;

}


}

}
}
else
{ header("Location: login.php"); exit (0); } 

ob_flush(); 
?>

 

When i run it the image is uploaded to the server but the db row isnt updated. Yet when i echo the query and put that into phpmyadmin it works fine. So why doesnt it work in php?

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/182552-update-not-working/
Share on other sites

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.