Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8012325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:17:47+00:00 2026-06-04T19:17:47+00:00

I am working on a website and my task is to take product image

  • 0

I am working on a website and my task is to take product image from user and store that image in the database..i am using mysql database.
My code for html form is as:-

      <FORM action="testimage1.php" ENCTYPE="multipart/form-data" method="post">
              <div style="font:bold 10px arial,serif;" >Product Name*</div>
              <input type="text" name="myuserName" maxlength="50" /><br />
             <div style="font:bold 10px arial,serif;" >Upload a photo</div>
               <input name="uploadimage" type="file" /></br>
              <div style="font:bold 10px arial,serif;">Product Description:</div> 
              <input type="text" name="product" value=""></br>
              <input id="submit" type="submit" value="submit" /><br />
     </FORM>

My code for testimage1.php is as:-

           require_once("dbconnect.inc.php");                       
    $db_name="thinstrokes";                                     //for localhost databasename
     $tbl_name="product";
     $db_selected=mysql_select_db("$db_name")or die("cannot select DB");

    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['product'];
    $filename=$_FILES['uploadimage']['tmp_name']; 
    $imgData = file_get_contents($filename);
    $size = getimagesize($filename);
    $sql = "INSERT INTO product
    (productname, image_id , image_type ,image, image_size, image_name,   productdesc)VALUES
    ('$myusername','11', '{$size['mime']}', '{$imgData}', '{$size[3]}', 
     '{$_FILES['userfile']['name']}','$productdesc')";
    $result=mysql_query($sql) or die("error in uploading/*");

and i am getting an error as:-error in uploading/*
how can i correct it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T19:17:48+00:00Added an answer on June 4, 2026 at 7:17 pm

    try to change this:

    $sql = "INSERT INTO product
    (productname, image_id , image_type ,image, image_size, image_name, productdesc)VALUES
    ('$myusername','11', '{$size['mime']}', '{$imgData}', '{$size[3]}', 
    '{$_FILES['userfile']['name']}','$productdesc')";
    

    with this:

    $size_mime = mysql_real_escape_string($size['mime']);
    $size3 = mysql_real_escape_string($size[3]);
    $filename = mysql_real_escape_string($_FILES['userfile']['name']);
    $sql = "INSERT INTO product
    (productname, image_id , image_type ,image, image_size, image_name, productdesc) VALUES
    ('{$myusername}','11', '{$size_mime}', '{$imgData}', '{$size3}', 
    '{$filename}','$productdesc')";
    

    and edit this:

    $myusername=$_POST['myusername']; 
    $mypassword=$_POST['product'];
    $filename=$_FILES['uploadimage']['tmp_name'];
    

    with this:

    $myusername = mysql_real_escape_string($_POST['myusername']); 
    $mypassword = mysql_real_escape_string($_POST['product']);
    $filedata = mysql_real_escape_string($_FILES['uploadimage']['tmp_name']);
    

    you should absolutely avoid sql injection!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a website that has Employee and Branch entities, using a database table
Im working on a website (html,css,javascript, ajax, php,mysql), and I want to restrict the
I'm working on a website that will be using Facebook Connect to authenticate users.
I'm refactoring some code so that my app will pull data from a website
hey i guys i want help from you. i am working on website project,
I'm working on a website that will use features of social networking (like facebook
I'm working on a site that's grown both in terms of user-base and functionality
I've inherited some code that I need to debug. It isn't working at present.
I have a website that's working with Facebook Connect (or Facebook for Websites as
I'm working on the quite popular website, which looks good if user has turned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.