I am having a little issue on some fields during an INSERT into MySQL
The query is as follows:
INSERT INTO sforce_account (ID, NAME, billingstreet, billingcity, billingstate, billingpostalcode, billingcountry) VALUES ('0015000000Klo64AAB', 'Mitac Int'l', '6th Fl.,no. 187, TIDING BLVD., Sec. 2,', 'Taipei','Taiwan', '303','' )
error is:
1064: 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 'l', '6th Fl.,no. 187, TIDING BLVD., Sec. 2,', 'Taipei','Taiwan', ' at line 2
php code is:
foreach ($accounts as $r)
{
$r = new SObject($r);
$pass_this['id'] = $r->Id;
$pass_this['name'] = $r->fields->Name;
$pass_this['billingstreet'] = addslashes($r->fields->BillingStreet);
$pass_this['billingcity'] = addslashes($r->fields->BillingCity);
$pass_this['billingstate'] = addslashes($r->fields->BillingState);
$pass_this['billingpostalcode'] = addslashes($r->fields->BillingPostalCode);
$pass_this['billingcountry'] = addslashes( $r->fields->BillingCountry);
//echo '<pre>' . print_r($r, true) . '</pre>';
//exit;
$sql = $db->execute("INSERT INTO sforce_account (ID, NAME, billingstreet, billingcity, billingstate, billingpostalcode, billingcountry)
VALUES ('{$pass_this['id']}', '{$pass_this['name']}', '{$pass_this['billingstreet']}', '{$pass_this['billingcity']}','{$pass_this['billingstate']}',
'{$pass_this['billingpostalcode']}','{$pass_this['billingcountry']}' )");
if(!$sql)
{
echo "Error performing query: ".$db->ErrorMsg()."<br />";
}
else
{
echo "Query success!<br />";
}
}
I added addslashes() for a prior error and it worked. Can someone give me an idea of what I need to do to clean up fields and explain to me why this (and other records like this) are erroring?
TIA,
Mike