Getting JSON Parsing Error & SQL Syntax Error
Getting JSON Parsing Error & SQL Syntax Error
PriceGuideApp
Posts: 3Questions: 0Answers: 0
First of all - great tool, and I've gotten it to work reading from an AJAX source - but I have over 20,000 data sets & adding more, so I need server side processing.
I'm not really sure why it doesn't work, below is my .php file code, I get a pop up box saying JSON can't parse. I see an error in the debugger that says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set, card_no, player_name, serial_no
FROM orders
ORDE' at line 1
URL: http://www.priceguideapp.com/test/main.html
[code] $aColumns = array( 'sport', 'set', 'card_no', 'player_name', 'serial_no', 'price' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "orders";
/* Database connection information */
$gaSql['user'] = "foo";
$gaSql['password'] = "bar";
$gaSql['db'] = "myDB";
$gaSql['server'] = "localhost";[/code]
Here is my HTML:
[code]
Price Guide App Beta 1.1
@import "/media/css/demo_page.css";
@import "/media/css/demo_table.css";
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
{ "sWidth": "10%" },
null,
{ "sWidth": "7%" },
{ "sWidth": "35%" },
{ "sWidth": "7%" },
{ "sWidth": "10%" }
],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/scripts/server_processing.php"
} );
} );
[/code]
Any ideas? I'm sure it's something pretty easy, but I can't seem to get the data to load. Doesn't look like it's even returning the data. Thanks, I'll be donating next payday.
I'm not really sure why it doesn't work, below is my .php file code, I get a pop up box saying JSON can't parse. I see an error in the debugger that says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'set, card_no, player_name, serial_no
FROM orders
ORDE' at line 1
URL: http://www.priceguideapp.com/test/main.html
[code] $aColumns = array( 'sport', 'set', 'card_no', 'player_name', 'serial_no', 'price' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "id";
/* DB table to use */
$sTable = "orders";
/* Database connection information */
$gaSql['user'] = "foo";
$gaSql['password'] = "bar";
$gaSql['db'] = "myDB";
$gaSql['server'] = "localhost";[/code]
Here is my HTML:
[code]
Price Guide App Beta 1.1
@import "/media/css/demo_page.css";
@import "/media/css/demo_table.css";
$(document).ready(function() {
$('#example').dataTable( {
"aoColumns": [
{ "sWidth": "10%" },
null,
{ "sWidth": "7%" },
{ "sWidth": "35%" },
{ "sWidth": "7%" },
{ "sWidth": "10%" }
],
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/scripts/server_processing.php"
} );
} );
[/code]
Any ideas? I'm sure it's something pretty easy, but I can't seem to get the data to load. Doesn't look like it's even returning the data. Thanks, I'll be donating next payday.
This discussion has been closed.
Replies
$sIndexColumn = "id";
to
$sIndexColumn = "sport"; ?
Either way, the AJAX source works for now, and I'll be testing the server side. If that's not the problem - or I find a work around, I'll try to update this.
Glad that the table works. To test your " ' " problem, I changed some of my data to include an ' in one of the cells in the mysql table and datatables rendered it with no problems.
I ended up running some tests and found out that one of my columns was named 'set' and for some reason that caused the above error.
Changed it to 'set_name' and it works ... lol
Simple fix, so if you have this problem - try re-naming some of your columns and maybe that will do the trick.