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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.