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.


mysql_connect("","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'];

	echo "Please Fill in Fields to add a new Product";
		$image = addslashes(file_get_contents($_FILES['image']['tmp_name']));	
		$image_name = addslashes($_FILES['image']['name']);
		$image_size = getimagesize($_FILES['image']['tmp_name']);
			echo "This is not an Image";
				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.";
					$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:

mysql_connect("","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?

Recommended Answers

All 3 Replies

I have changed the <img src=get.php?number=$lastid> to id like it should be and it still doesnt work

It means you need to contact your web host and tell them that mysql needs the my.cnf file repairing unless you own a dedicated server, vps, xampp or wamp in which case it will be more difficult. Usually this error indicates that mysql hasn't had a correct installation and in fact I just fixed this devil of an error recently and turned out to be a permissions problem on linux as the directory needed permissions. In addition I had to dig deep into the system to change a system file to change the path of the mysql socket location in addition to the one specified in the my.cnf file. So if this is happpening on your shared web hosting account then please file a support ticket and they should get right on it.

Thanks a lot!

I am going to call my hosting company right away and see what they have to say about it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.