Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL Server来自PHP的奇怪字符,但不是手动查询_Php_Sql Server - Fatal编程技术网

SQL Server来自PHP的奇怪字符,但不是手动查询

SQL Server来自PHP的奇怪字符,但不是手动查询,php,sql-server,Php,Sql Server,我有php代码,可以使用下面的语句将数据更新到sql server UPDATE [table] SET [third]='Several times (2–5x)' WHERE ... 但是,sql server中的更新数据多次显示奇怪的字符(2–5x),但是如果我尝试在Management Studio中执行sql语句,它不会给我奇怪的字符 以下是我的PHP代码: $sql = "UPDATE [table] SET [third]='Several times (2–5x)' WHERE

我有php代码,可以使用下面的语句将数据更新到sql server

UPDATE [table] SET [third]='Several times (2–5x)' WHERE ...
但是,sql server中的更新数据多次显示奇怪的字符
(2–5x)
,但是如果我尝试在Management Studio中执行sql语句,它不会给我奇怪的字符

以下是我的PHP代码:

$sql = "UPDATE [table] SET [third]='Several times (2–5x)' WHERE ..."
$sql_update_user_result = odbc_exec($connection, $sql);

我做错了什么?

对我来说似乎是编码问题

在执行更新查询之前,请尝试查询“SET NAMES utf8”

odbc_exec($connection, "SET NAMES utf8");

$sql = "UPDATE [table] SET [third]='Several times (2–5x)' WHERE ..."
$sql_update_user_result = odbc_exec($connection, $sql);

2–5x中的连字符不是ascii减号,而是另一个类似的拼音符号(u+2013)。
只需删除–并键入-。

iSWORD,我不确定为什么集合名称对我的Insert语句不起作用:(刚刚发现,实际上它给了我这个错误:[Microsoft][ODBC SQL Server Driver][SQL Server]“名称”不是一个可识别的集合选项…我不确定它以前为什么起作用。。