0

error Please select an imageError: Duplicate entry '' for key 'img'

`

                   //file properties
$file = $_FILES['image']['tmp_name'];


if(!isset($file))
    echo "Please select an image";
else
{
    $image = addslashes(file_get_contents($_FILES['image']['tmp_name']));
    $image_name = addslashes($_FILES['image']['img']);
    $image_size = getimagesize($_FILES['image']['tmp_name']);


    if($image_size==FALSE)
        echo "That's not an image.";
    else
    {
        {
        if(!$insert =  msql_query("INSERT INTO shop (id, img, name, description, price, product_qty,  product_category,imagesize)  
                                             VALUES ('','$image_name', '','','','','','$image')"))
            echo "Problem uploading image.";
        else
        {
        $lastid = mysql_insert_id();
        echo "image uploaded.<p />Your image :<p /><img src=get.php?id=$lastid>";
        }   

    }   
}   
}
2
Contributors
4
Replies
5
Views
5 Years
Discussion Span
Last Post by vibhaJ
0

yes i have problem in saving my plaod photo in the database instead of pic.1.png -- in my database its said images/products/.png ---------------im doing a shopping cart .admin panel please help for my thesis

0

heres my new code

  // Image Load 


//file properties
$file = $_FILES['image']['tmp_name'];

                        if(!isset($file))
                            echo "Please select an image";
                        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 "That's not an image.";
                        else
                    {
                        if(!$insert =  msql_query("INSERT INTO shop VALUES('$st_id','$image_name','$productname','$image' ,'$description','$price','$product_qty','$_REQUEST[product_category]' "))
                            echo "problem uploading image";
                        else 
                            {
        $lastid = mysql_insert_id();
        echo "image uploaded.<p />Your image :<p /><img src=get.php?id=$lastid>";
        }

                    }
                    }
                    }}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.