【发布时间】:2013-11-21 07:22:14
【问题描述】:
服务器端数据表。除搜索框外,一切正常。当我在搜索中输入一个字符时,就会出现这个错误:
DataTables warning (table id = 'sample_1'): DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number' in /home/test/public_html/assets/data-tables/test-pdo.php:99
Stack trace:
#0 /home/test/public_html/assets/data-tables/test-pdo.php(99): PDOStatement->execute()
#1 /home/test/public_html/assets/data-tables/test-pdo.php(143): TableData->get('accounts', 'account_id', Array)
#2 {main}
thrown in /home/test/public_html/assets/data-tables/test-pdo.php on line 99
第 99 行是来自绑定参数的 -$statement->execute();
我正在对列出的数据表使用 pdo 脚本here
【问题讨论】:
-
这是php错误,很可能你没有传递足够的参数来绑定
-
这实际上是因为我在我的数据库连接中使用 PDO::ATTR_EMULATE_PREPARES => false。此第 3 方脚本的搜索部分和绑定未正确完成。如果我打开“模拟”,它工作正常。
-
您的问题中没有足够的信息来回答这个问题。您是如何构建搜索查询的?
-
它说明了下一个调试步骤的一切:
JSON data from server could not be parsed。使用网络工具(在 chrome、firebug、IE10+ 中内置?),看看你的服务器的答案是什么。在一些 JSON 检查器中复制 JSON 字符串。硬编码服务器在您的 JavaScript 中发送的 JSON 字符串。操作字符串直到它起作用。然后操作服务器/PHP,直到他使用硬编码的 JSON 字符串以正确的格式发送 JSON。 -
json 是有效的......对于一切,但搜索。在萤火虫中,我没有提供在搜索时发送的 json 只是错误。
标签: php jquery jquery-datatables