Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Uploading Pictures to mysql

sweeneysweeney Member Posts: 117
Hi, I am developing a website for a magazine shop! and In the admin page i have add new product, the product has 5 fields, ProdID is an auto increment, ProdName, ProdDiscrip, ProdCost and ProdPic. The Problem I am having is with the ProdPic, This is to hold the picture of the magazine, I have tried saving it as a blob, then saving it as text but its just keeps coming up with the box with a red x. I am using a brows button to find the file and write it to the php page. I echo what the value of the brows feild, for example my images are saved in an image folder, U:wwwwishingimagesactionfigures.jpg but in the mysql database there are no . here is the code I have so far:

Html Add New Prod

Insert New Product

This Page Will Allow You To Insert A New Product

Press To Go Back To Admin Page!

Product Name:

Product Discription:

Product Cost:

Product Picture

Php Add New Prod

Insert New Product

Press To Go Back To Admin Page!

//Get Values From HTML Form
$prodname = $_POST['prodname'];
$proddiscript = $_POST['proddiscript'];
$prodcost = $_POST['prodcost'];
$prodpic = $_POST['pic'];
echo $prodpic;

$user = "root";
$password = "no";
$database = "wishingwell";

// Connect to Database
@mysql_select_db($database) or die("Please Contact A Member Of Adminatration!");

// Query
$query = "INSERT INTO tblproducts VALUES('','$prodname','$proddiscript','$prodcost','$prodpic')";

// Close Database
// Message
echo "New Product Added";


View Products php

View Products

Press To Go Back To Admin Page!


$user = "root";
$password = "no";
$database = "wishingwell";

// Connect To The Database
@mysql_select_db($database) or die("Try Again If This Message comes up conntact Adminatration!");

// Query
$query = "Select * From tblproducts";

//number of records
$result = mysql_query($query);
$num = mysql_numrows($result);

// print number of records
echo "<b> There Are $num Products Saved";

// Close database

// Inizialise counter

//Create A While loop so that it will loop through all records puting the values under the headings
while ($i < $num)
{ // Start While loop

//Put all values from database into varables



// Incroment Counter

} // End While Loop


Thank You For Reading This, and I hope Someone Has The Answer
Product ID Product Name Product Discription Product Cost Product Picture
<? echo $prodID; ?> <? echo $prodname; ?> <? echo $proddis; ?> <? echo $prodcost; ?> image">


  • treshrtreshr Member Posts: 326
    [b][red]This message was edited by Moderator at 2005-3-11 1:7:17[/red][/b][hr]
    The thing you could do is to create a config file that holds a constant that refers to the directory that holds the pictures. Together with only the name of the file saved into a field in the database with the path picked up from the constant should show you the picture.

    I created a conf file that looks like this:
    define("HOSTNAME", "localhost");
    define("USERNAME", "gebruiker");
    define("PASSWORD", "gebruiker99");

    Hope this helps you a bit.

    Good luck,


Sign In or Register to comment.