2

Server-side datatables. everything is working fine except the search box. Soon as I enter one character in the search, this error shows up:

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

line 99 is -$statement->execute(); from Bind Parameters

I am using the pdo script for datatables listed here

5
  • it is php error, most probably you not passed enough arguments to bind Commented Dec 7, 2013 at 17:25
  • It's actually because I am using PDO::ATTR_EMULATE_PREPARES => false in my db connection. Something with the search part of this 3rd party script and the binding is not done properly. If I turn 'on' emulation it works fine. Commented Dec 7, 2013 at 20:02
  • There is not enough information in your question to answer this. How are you building your search query? Commented Dec 11, 2013 at 15:17
  • It says everything for the next debug steps: JSON data from server could not be parsed. Use a network tool (buildin in chrome, firebug, IE10+?), and see what's the answer of your server. Copy the JSON String in some JSON Checker. Hardcode the JSON String the server sends in your JavaScript. Manipulate the string until it works. Then manipulate the server/PHP until he sends the JSON with the right format that you found out with the hardcoded JSON string. Commented Dec 12, 2013 at 16:04
  • The json is valid... for everything, but searching. In firebug I am not provided the json sent on a search just the error. Commented Dec 12, 2013 at 16:44

3 Answers 3

4
+25

this is a SQL error not Jquery... Please check your passed parameters..

Sign up to request clarification or add additional context in comments.

Comments

1

The error which you are receiving is because you went something wrong in your php code. jQuery just loads your php page and gives you the output.


In your php code, try setting emulate prepares to false which may be causing the problem. It worked for me when I set it to false.

1 Comment

Yes, I know this... I want to fix the problem while keeping 'PDO::ATTR_EMULATE_PREPARES => false' set for my db connection.
0

Validate your JSon response here http://jsonlint.com/ Check if its an invalid or a valid JSON.
Also your Jquery is firing command as soon as you enter some data in search box.
Try checking the Database attribute type for errors (Number or text).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.