Reputation: 1
I am building a profile pictures system and for some reason my table doesn't seem to be working with the MYSQL UPDATE query. Below you should just select your image and click upload, it moves the image to the folder but not the directory to the database.
Help please:
if (file_exists("userdata/profile_pics/".@$_FILES["profilepic"]["name"]))
{
echo @$_FILES["profilepic"]["name"]." Already exists";
}
else
{
move_uploaded_file(@$_FILES["profilepic"]["tmp_name"],"userdata/profile_pics/".$_FILES["profilepic"]["name"]);
echo "Uploaded and stored in: userdata/profile_pics/".@$_FILES["profilepic"]["name"];
$profile_pic_name = @$_FILES["profilepic"]["name"];
$profile_pic_query = mysql_query("UPDATE users SET profile_pic='$profile_pic_name' WHERE username={$_SESSION['user_login']}");
}
}
else
{
echo "Invailid File! Your image must be no larger than 1MB and it must be either a .jpg, .jpeg, .png or .gif";
}
}
Upvotes: 0
Views: 108
Reputation: 4046
try session variable put into quotes username='".$_SESSION['user_login']."'
Upvotes: 0
Reputation: 26376
Try this: add quote to the username variable
$username = $_SESSION['user_login'];
"...WHERE username='$username'";
Upvotes: 1