The setup is simple. A Joomla eCommerce site (MySQL back-end) that sends data (cURL post) to another database backed application (ASP with MS SQL) after a Joomla account has been created.
The problem is that sometimes this data is stored on the receiving database without any white spaces. For example: an address collected on the Joomla site is stored in the database as "123 example road" but on the receiving database it's being stored as "123exampleroad". This doesn't happen all of the time - so I'm rather baffled at what the cause might be.
Has anyone experienced such an issue? Any help is appreciated.
This is what the cURL code looks like:
//create array of data to be posted
foreach( $registrationfields as $field ) {
if( $field->name == 'email') $field->name = 'user_email';
if( $field->name == 'delimiter_sendregistration') continue;
if( $field->type == 'captcha') continue;
if( $field->type == 'delimiter') continue;
switch($field->name) {
case 'country':
require_once(CLASSPATH.'ps_country.php');
$country = new ps_country();
$dbc = $country->get_country_by_code($dbbt->f($field->name));
if( $dbc !== false ) $val = $dbc->f('country_name');
break;
default:
$val = $dbbt->f($field->name);
break;
}
$post_data[$field->name] = $val;
}
$post_data['order_id'] = $order_id;
$post_data['order_date'] = $order_date;
$post_data['order_status'] = $order_status;
$post_data['username'] = $username;
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection =
curl_init('http://--url-here');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);