Jump to content

im have error inserting image data


Spraban9
Go to solution Solved by AyKay47,

Recommended Posts

hi friends

i get this error to insert data

"Database query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'add,city, date, image) VALUES ('car for sale','mp','car for sale', '0115478956',' at line 1".

 <?php
// May 25, 2010
		 
 include("include/connection.php");
   
if (isset($_FILES['file']) && $_FILES['file']['size'] > 0) { 
        // Temporary file name stored on the server
        
		$title = $_POST['title'];
		$catergory = $_POST['catergory'];
		$des = $_POST['des'];
		$phone=$_POST['phone'];
		$add = $_POST['add'];                                
		$city = $_POST['city'];
		$currentDate = date("F j, Y");
		$tmpName  = $_FILES['file']['tmp_name'];  
        // Read the file 
        $fp      = fopen($tmpName, 'r');
        $data = fread($fp, filesize($tmpName));
        $data = addslashes($data);
        fclose($fp);
		
        $result = mysql_query("INSERT INTO upload  (title, catergory, des, phone,add,city, date, image) VALUES
		 ('$title','$catergory','$des', '$phone','$add','$city','$currentDate','$file')",$conn);
        if(!$result)
        {
            die("Database query failed: ". mysql_error());
        }
        // Print results

        print "Thank you, your file has been uploaded.";
}
  

?>

 

Link to comment
Share on other sites

DATE you can get get away with but I'd advise avoiding it and always qualifying it, such as "date_added" or "invoice_date" etc

 

 

MySQL permits some keywords to be used as unquoted identifiers because many people previously used them. Examples are those in the following list:

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.