-2

我有一个查询问题。此查询适用于 phpMyAdmin,但当 PHP 执行此查询时出现错误。可能是什么原因?

我的 PHP 代码是:

var_dump($sql);
query($sql); 

当我调试时:

这是查询字符串:

 UPDATE searchcolumnsets SET name = "Project X",jsonfields = "[{\"name\":\"cm:contentPropertyName\",\"title\":\"Thumbnailed Content Property Name\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:defaultHomeFolderPath\",\"title\":\"Percorso cartella homepage\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"trx:enabled\",\"title\":\"Abilitato\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:identifier\",\"title\":\"Identificativo\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:expiryDate\",\"title\":\"Data di scadenza\",\"description\":\"Data di scadenza\",\"datatype\":\"d:date\"},{\"name\":\"cm:hits\",\"title\":\"Conteggio\",\"description\":\"Conteggio\",\"datatype\":\"d:int\"}]" WHERE id = 50

这是错误:

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的 'name":"cm:contentPropertyName","title":"Thumbnailed Content Property Name","desc' 附近使用正确的语法

4

1 回答 1

1

您可以改用单个 qoute。尝试这个

UPDATE searchcolumnsets SET name = 'Project X',jsonfields = '[{\"name\":\"cm:contentPropertyName\",\"title\":\"Thumbnailed Content Property Name\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:defaultHomeFolderPath\",\"title\":\"Percorso cartella homepage\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"trx:enabled\",\"title\":\"Abilitato\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:identifier\",\"title\":\"Identificativo\",\"description\":\"\",\"datatype\":\"\"},{\"name\":\"cm:expiryDate\",\"title\":\"Data di scadenza\",\"description\":\"Data di scadenza\",\"datatype\":\"d:date\"},{\"name\":\"cm:hits\",\"title\":\"Conteggio\",\"description\":\"Conteggio\",\"datatype\":\"d:int\"}]' WHERE id = 50
于 2012-07-05T09:16:37.147 回答