mercredi 15 avril 2015

How i upload blob image into my product table?

I have tried many ways to let my selected image uploaded into my product table but nothing happened no errors occurred here is my php code and form



<?php



//connect to the server and create database.
$host = "localhost";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");


//three pages one for form and anthor one for the search page.

/*if (isset($_POST['sSearch']))
{

processForm();
}*/


if (isset($_POST['sAddProduct']))
{

addNewProduct();
}

else if(isset($_POST['submit'])){

addNewImage();
}

else if(isset($_POST['delete']))
{
$Product_ID=$_POST['Product_ID'];
$mysqlquery="delete from Product where Product_ID= ".$Product_ID."";
mysql_query($mysqlquery);
echo "Deleted successfully";
echo("<FORM><INPUT Type='button' VALUE='Back' onClick='history.go(-1);return true;'></FORM>");
}
else
//hasn't yet been submitted, display the form
{
showForm();
}

function addNewProduct()
{
$ProductName = $_POST['Product_Name'];
$ProductPrice = $_POST['Price'];


//database query to add country
$insertStringProduct = "INSERT into Product(Product_Name, Price)
VALUE('$ProductName', '$ProductPrice')" ;
$result = mysql_query($insertStringProduct);
echo ("<p1>Product added Successfully</p1>");
echo("<FORM><INPUT Type='button' VALUE='Back' onClick='history.go(-1);return true;'></FORM>");




}


///////>>>>>>>>>>>>>>Here what i added but nothing happened<<<<<<<<<<<<<<<<<<<<<<<
function addNewImage(){

$image = $_POST['Image'];
$sql = "INSERT INTO product
(Image)
VALUE
( '$image')" echo "Please Upload an image..";
$result=mysql_query($sql) or die("error in uploading/*");

}


Here is my database product table where you could find image row http://ift.tt/1Ics8ob


Aucun commentaire:

Enregistrer un commentaire