I have an update profile page where you can select an image from your folders and upload it to my MySQL database. Look at this code:
$image ="";
$image_size;
$image_name;
$uploadable = false;
if(isset($_FILES['image']['tmp_name'])){
$image= file_get_contents($_FILES['image']['tmp_name']);
$image_name=$_FILES['image']['name'];
$image_size=getimagesize($_FILES['image']['tmp_name']);
if($image_size==false){
$_SESSION["FLAW"] = '4';
header("Location:editprofile.php");
echo "nope";
$uploadable = false;
}else{
$uploadable = true;
}
}else{}
AND:
if($row[6] == $id && $uploadable == true){
if(($fetchedemail == $emailentered) || ($fetchedemail != $emailentered && ($new == true)) ){
$query = mysql_query("UPDATE `allaccounts` SET `realname` = '$realname' WHERE `allaccounts`.`id` = $id;");
$query2 = mysql_query("UPDATE `allaccounts` SET `twitter` = '$twitter' WHERE `allaccounts`.`id` = $id;");
$query1 = mysql_query("UPDATE `allaccounts` SET `email` = '$emailentered' WHERE `allaccounts`.`id` = $id;");
$query3 = mysql_query("UPDATE `allaccounts` SET `facebook` = '$facebook' WHERE `allaccounts`.`id` = $id;");
$query4 = mysql_query("UPDATE `allaccounts` SET `description` = '$description' WHERE `allaccounts`.`id` = $id;");
$query5 = mysql_query("UPDATE `allaccounts` SET `image` = '$image' WHERE `allaccounts`.`id` = $id;");
$query6 = mysql_query("UPDATE `allaccounts` SET `filename` = '$image_name' WHERE `allaccounts`.`id` = $id;");
// header("Location:Myprofile.php");
$_SESSION["FLAW"] = '';
break;
}else{
//header("Location:editprofile.php");
$_SESSION["FLAW"] = '3';
break;
}
This is the PHP code I use to get the image from the form on my HTML page and then update the image column of my MYSQL database which is a BLOB type. I went to check the database but the data is not there and I don't know why. If I open my image in notepad it looks like it has all the data with the weird symbols, which is good. But if I echo $image it looks different and has a lot of diamonds with question mark symbols. That might indicate something is wrong. Can anyone see what I am doing wrong that doesn't get the code correctly or upload it correctly