Server-side postgres database // JSON format error
Server-side postgres database // JSON format error
clzstudi
Posts: 1Questions: 0Answers: 0
Hello,
i found this site: http://datatables.net/development/server-side/php_postgres and i change my code to the one from the server (okay, i had to make some changes for db-connection:
[code]
<?php
/*
* Script: DataTables server-side script for PHP and PostgreSQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
require_once($_SERVER['DOCUMENT_ROOT'].'newesw/files/auth.inc');
$aColumns = array( 'von_konto', 'zu_konto', 'zeit', 'betrag', 'verwendungszweck' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "von_konto";
/* DB table to use */
$sTable = "buchungen";
/* Database connection information
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "";*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* DB connection
$gaSql['link'] = pg_connect(
" host=".$gaSql['server'].
" dbname=".$gaSql['db'].
" user=".$gaSql['user'].
" password=".$gaSql['password']
) or die('Could not connect: ' . pg_last_error());
*/
$gaSql['link'] = $db;
[/code]
rest is the same. db-connection works, and i get a string of information as an answer, if i start the server-side script directly. But the website always says: JSAN-Format error.
the answer:
[quote]
{"sEcho":0,"iTotalRecords":37504,"iTotalDisplayRecords":5,"aaData":[["486","485","2008-11-06 00:07:14.675611+01","120.890","Initiales Guthaben"],["486","493","2008-11-06 00:11:51.686658+01","2017.210","Initiales Guthaben"],["486","492","2008-11-06 00:12:23.37518+01","89.500","Initiales Guthaben"],["486","491","2008-11-06 00:12:37.015867+01","20.000","Initiales Guthaben"],["485","493","2008-11-06 11:47:09.398729+01","84.200","Barauszahlung"]]}[/quote]
okay, the "sEcho" is 0, becourse i start the script direkctly ( i think so) but where is my mistake?
greetings
i found this site: http://datatables.net/development/server-side/php_postgres and i change my code to the one from the server (okay, i had to make some changes for db-connection:
[code]
<?php
/*
* Script: DataTables server-side script for PHP and PostgreSQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
require_once($_SERVER['DOCUMENT_ROOT'].'newesw/files/auth.inc');
$aColumns = array( 'von_konto', 'zu_konto', 'zeit', 'betrag', 'verwendungszweck' );
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "von_konto";
/* DB table to use */
$sTable = "buchungen";
/* Database connection information
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "";*/
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/
/*
* DB connection
$gaSql['link'] = pg_connect(
" host=".$gaSql['server'].
" dbname=".$gaSql['db'].
" user=".$gaSql['user'].
" password=".$gaSql['password']
) or die('Could not connect: ' . pg_last_error());
*/
$gaSql['link'] = $db;
[/code]
rest is the same. db-connection works, and i get a string of information as an answer, if i start the server-side script directly. But the website always says: JSAN-Format error.
the answer:
[quote]
{"sEcho":0,"iTotalRecords":37504,"iTotalDisplayRecords":5,"aaData":[["486","485","2008-11-06 00:07:14.675611+01","120.890","Initiales Guthaben"],["486","493","2008-11-06 00:11:51.686658+01","2017.210","Initiales Guthaben"],["486","492","2008-11-06 00:12:23.37518+01","89.500","Initiales Guthaben"],["486","491","2008-11-06 00:12:37.015867+01","20.000","Initiales Guthaben"],["485","493","2008-11-06 11:47:09.398729+01","84.200","Barauszahlung"]]}[/quote]
okay, the "sEcho" is 0, becourse i start the script direkctly ( i think so) but where is my mistake?
greetings
This discussion has been closed.
Replies
Allan