设置很简单。创建 Joomla 帐户后,将数据(cURL 发布)发送到另一个数据库支持的应用程序(带有 MS SQL 的 ASP)的 Joomla 电子商务站点(MySQL 后端)。
问题是有时这些数据存储在接收数据库中,没有任何空格。例如:在 Joomla 网站上收集的地址在数据库中存储为“123 exampleroad” ,但在接收数据库中,它被存储为“123exampleroad”。这不会一直发生 - 所以我对可能的原因感到困惑。
有没有人遇到过这样的问题?任何帮助表示赞赏。
这是 cURL 代码的样子:
//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);