This is what I have for a main page and form and upload code for an image.
The image information is stored in a Blob field in phpMyAdmin.
<?php
error_reporting(0);
mysql_connect("sql5c1d.megasqlservers.com","vincastweb356440","fakepassword") or die(mysql_error());
mysql_select_db("phpmy1_vincastweb_com") or die(mysql_error());
$picture = $_FILES['image']['tmp_name'];
$brand = $_POST['brand'];
$year = $_POST['year'];
$story = $_POST['story'];
$description = $_POST['description'];
$why = $_POST['why'];
$peers = $_POST['peers'];
$intensity = $_POST['intensity'];
$body = $_POST['body'];
$sweet = $_POST['sweet'];
$acid = $_POST['acid'];
$oak = $_POST['oak'];
$lcbo = $_POST['lcbo'];
$size = $_POST['size'];
$btl = $_POST['btl'];
$price = $_POST['price'];
$lto = $_POST['lto'];
if(!isset($picture))
echo "Please Fill in Fields to add a new Product";
else
{
$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
$image_name = addslashes($_FILES['image']['name']);
$image_size = getimagesize($_FILES['image']['tmp_name']);
if($image_size==FALSE)
echo "This is not an Image";
else{
if(!$insert = mysql_query ("INSERT INTO product_information VALUES ('','$image_name','$image','".$brand."','".$year."','".$story."','".$description."','".$why."','".$peers."','".$intensity."','".$body."','".$sweet."','".$acid."','".$oak."','".$lcbo."','".$size."','".$btl."','".$price."','".$lto."')"))
echo "Problem Uploading Image.";
else{
$lastid = mysql_insert_id();
echo "Image Uploaded!
<p /><strong>Brand:</strong> ".$brand."<p />
<p /><strong>Year:</strong> ".$year."<p />
<p /><strong>Story:</strong> ".$story."<p />
<p /><strong>Description:</strong> ".$description."<p />
<p /><strong>Why Drink?:</strong> ".$why."<p />
<p /><strong>Peers:</strong> ".$peers."<p />
<p /><strong>Intensity:</strong> ".$intensity."<p />
<p /><strong>Body:</strong> ".$body."<p />
<p /><strong>Sweet:</strong> ".$sweet."<p />
<p /><strong>Acidity:</strong> ".$acid."<p />
<p /><strong>Oak:</strong> ".$oak."<p />
<p /><strong>LCBO Number:</strong> ".$lcbo."<p />
<p /><strong>Size:</strong> ".$size."<p />
<p /><strong>BTL:</strong> ".$btl."<p />
<p /><strong>Price:</strong> ".$price."<p />
<p /><strong>LTO:</strong> ".$lto."<p />
<p /><strong>Your Image:</strong><p />
<img src=get.php?number=$lastid>";
}
}
}
?>
This is my get.php page:
<?php
mysql_connect("sql5c1d.megasqlservers.com","vincastweb356440","fakepassword") or die(mysql_error());
mysql_select_db("phpmy1_vincastweb_com") or die(mysql_error());
$id = addslashes($_REQUEST['id']);
$image = mysql_query("SELECT* FROM product_information WHERE pro_id=$id");
$image = mysql_fetch_assoc($image);
$image = $image['pic_info'];
header("Content-type: image/jpeg");
echo $image;
?>
my issue is that I cant display the image on a server.
everything worked fine on my local server, then i uploaded it and change the server information. Again everything was fine with the uploads but i cannot display the picture..
when i try and just go to the get.php page I get this message:
"Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)"
anyone have any ideas?