You are here:  » Some information not passing into MYSQL


Some information not passing into MYSQL

Submitted by ROYW1000 on Wed, 2011-06-22 12:32 in

Hi

I am trying to pass this feed and get the following error

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 'merchant_logo = 'http://www.example.com/merchant_logo/0044.co.uk.gif' network' at line 5

{link saved}

merchant_logo = '".mysql_real_escape_string($record["MERCHANT_LOGO_URL"] )."'

Do I need to change the code or anything to pass this information into the mysql database.

Thanks
Roy

Submitted by support on Wed, 2011-06-22 12:40

Hi Roy,

The SQL syntax error is actually more likely to be either side of that position in the code rather than anything to do with generating the merchant_logo SQL (in this example). Could you post the full line of code where you are making the SQL and I'll take a look...

Perhaps also if you could add some debug code, e.g. if you are constructing a variable called $sql then add the following:

  print $sql;

...and let me know the full SQL that is being generated and I should be able to spot the SQL error from that...

Thanks,
David.

Submitted by ROYW1000 on Wed, 2011-06-22 12:50

Hi

This is the entire script.

{code saved}

Debug info:

{code saved}

Thanks
Roy

Submitted by support on Wed, 2011-06-22 13:09

Thanks, Roy.

I can see from the SQL that there are some commas missing between fields. In your code, where you have this line:

$sql = "INSERT INTO icodes_merchants SET
        item = '".mysql_real_escape_string($record["ITEM"] )."',
        icid = '".mysql_real_escape_string($record["ICID"] )."',
        relationship = '".mysql_real_escape_string($record["RELATIONSHIP"] )."'
        merchant_logo = '".mysql_real_escape_string($record["MERCHANT_LOGO_URL"] )."'
        network = '".mysql_real_escape_string($record["NETWORK"] )."'
        category = '".mysql_real_escape_string($record["CATEGORY"] )."'
        total_offers = '".mysql_real_escape_string($record["TOTAL_OFFERS"] )."'
        affiliate_url = '".mysql_real_escape_string($record["AFFILIATE_URL"] )."'
        merchant_url = '".mysql_real_escape_string($record["MERCHANT_URL"] )."'
";

...REPLACE that with:

$sql = "INSERT INTO icodes_merchants SET
        item = '".mysql_real_escape_string($record["ITEM"] )."',
        icid = '".mysql_real_escape_string($record["ICID"] )."',
        relationship = '".mysql_real_escape_string($record["RELATIONSHIP"] )."',
        merchant_logo = '".mysql_real_escape_string($record["MERCHANT_LOGO_URL"] )."',
        network = '".mysql_real_escape_string($record["NETWORK"] )."',
        category = '".mysql_real_escape_string($record["CATEGORY"] )."',
        total_offers = '".mysql_real_escape_string($record["TOTAL_OFFERS"] )."',
        affiliate_url = '".mysql_real_escape_string($record["AFFILIATE_URL"] )."',
        merchant_url = '".mysql_real_escape_string($record["MERCHANT_URL"] )."'
";

(no comma after the last one of course)

That should be all it is!
Cheers,
David.