gpt4 book ai didi

php - 错误的字符串值 : '\xCC_a' for column

转载 作者:行者123 更新时间:2023-11-29 14:13:58 25 4
gpt4 key购买 nike

收到错误:

Error Number: 1366

Incorrect string value: '\xCC_a' for column 'last_name' at row 1

UPDATE phppos_people SET first_name = 'Juan Gordon', last_name = 'Garc�_a', email = 'EMAIL@email.com', phone_number = '', address_1 = '', address_2 = '', city = '', state = '', zip = '', country = '', comments = '' WHERE person_id = '238'

Filename: /Library/WebServer/Documents/PHP-Point-Of-Sale/models/person.php

Line Number: 85

代码:

//Skip first row
fgetcsv($handle);
while (($data = fgetcsv($handle)) !== FALSE)
{
$person_data = array(
'first_name'=>$data[0],
'last_name'=>$data[1],
'email'=>$data[2],
'phone_number'=>$data[3],
'address_1'=>$data[4],
'address_2'=>$data[5],
'city'=>$data[6],
'state'=>$data[7],
'zip'=>$data[8],
'country'=>$data[9],
'comments'=>$data[10]
);

$customer_data=array(
'account_number'=>$data[11]=='' ? null:$data[11],
'taxable'=>$data[12]=='' ? 0:1,
'company_name' => $data[13],
);
if($this->Customer->exists($data[14]))
{
$this->Customer->save($person_data,$customer_data,$data[14]);
}
else if(!$this->Customer->save($person_data,$customer_data))
{
echo json_encode( array('success'=>false,'message'=>lang('customers_duplicate_account_id')));
return;
}
}

数据库列使用utf8_unicode_ci编码

我尝试使用 utf8_encode,但这不起作用

最佳答案

您的编码有问题。要解决这个问题,您应该在存储之前对值调用 utf8_encode 函数,就像这样。

$person_data = array(
'first_name' => $data[0],
'last_name' => utf8_encode($data[1]),
...

我也使用CodeIgniter,数据库配置是:

$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';

关于php - 错误的字符串值 : '\xCC_a' for column,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13002872/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com