Jump to content

[SOLVED] You have an error in your SQL syntax


Thomisback

Recommended Posts

Hi,

 

I get an error when executing my query but I don't get why, can someone please correct me?

 

$title = "Thomisback";

mysql_query("INSERT INTO `cscart_product_descriptions` (`product_id`, `lang_code`, `product`, `shortname`, `short_description`, `full_description`, `meta_keywords`, `meta_description`, `search_words`, `page_title`) VALUES 
($productid, 'EN', '$title', '', '', '', '$title', '$title', '$title', '$title'),
($productid, 'NL', '$title', '', '', '', '$title', '$title', $title'', '')")or die(mysql_error());

 

The error I get:

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 ''', '')' at line 3

Link to comment
Share on other sites

Make your life easier and create your query as a variable so you echo it to the page when an error occurs:

 

<?php
$title = "Thomisback";

$query = "INSERT INTO `cscart_product_descriptions`
            (`product_id`, `lang_code`, `product`, `shortname`,
             `short_description`, `full_description`, `meta_keywords`,
             `meta_description`, `search_words`, `page_title`)
          VALUES 
            ($productid, 'EN', '$title', '',
             '', '', '$title',
             '$title', '$title', '$title'),
            ($productid, 'NL', '$title', '',
             '', '', '$title', '$title',
            $title'', '')";

mysql_query($query) or die ("Query:<br />$query<br />Error:<br />".mysql_error());
?>

 

You would probably then see that the error is at the very end of the query:

            ($productid, 'NL', '$title', '',

             '', '', '$title', '$title',

            $title'', '')

There's a missing comma.

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.