sEcho returning value of 0

sEcho returning value of 0

cmandelacmandela Posts: 2Questions: 0Answers: 0
edited February 2014 in DataTables 1.9
I have used the code exactly as provided on your server-side example. When I run the code by itself values are returned but sEcho returns a value of 0 thus preventing the table to be populated. Any help on how to get sEcho to return a value?

Here is the data returned:
{"sEcho":0,"iTotalRecords":"72","iTotalDisplayRecords":"72","aaData":[["Alabama","AL"],["Alaska","AK"],["Arizona","AZ"],["Arkansas","AR"],["California","CA"],["Colorado","CO"],["Connecticut","CT"],["Delaware","DE"],["Florida","FL"],["Georgia","GA"],["Hawaii","HI"],["Idaho","ID"],["Illinois","IL"],["Indiana","IN"],["Iowa","IA"],["Kansas","KS"],["Kentucky","KY"],["Louisiana","LA"],["Maine","ME"],["Maryland","MD"],["Massachusetts","MA"],["Michigan","MI"],["Minnesota","MN"],["Mississippi","MS"],["Missouri","MO"],["Montana","MT"],["Nebraska","NE"],["Nevada","NV"],["New Hampshire","NH"],["New Jersey","NJ"],["New Mexico","NM"],["New York","NY"],["North Carolina","NC"],["North Dakota","ND"],["Ohio","OH"],["Oklahoma","OK"],["Oregon","OR"],["Pennsylvania","PA"],["Rhode Island","RI"],["South Carolina","SC"],["South Dakota","SD"],["Tennessee","TN"],["Texas","TX"],["Utah","UT"],["Vermont","VT"],["Virginia","VA"],["Washington","WA"],["West Virginia","WV"],["Wisconsin","WI"],["Wyoming","WY"],["American Samoa","AS"],["District of Columbia","DC"],["Micronesia","FM"],["Guam","GU"],["Marshall Islands","MH"],["Northern Mariana Islands","MP"],["Palau","PW"],["Puerto Rico","PR"],["Virgin Islands","VI"],["Alberta","AB"],["British Columbia","BC"],["Manitoba","MB"],["New Brunswick","NB"],["Newfoundland and Labrador","NL"],["Northwest Territories","NT"],["Nova Scotia","NS"],["Nunavut","NU"],["Ontario","ON"],["Prince Edward Island","PE"],["Quebec","QC"],["Saskatchewan","SK"],["Yukon","YT"]]}

Here is the link to the page to create the table: http://gsdeventsonline.com/Results/All_Dogs_Table.php
Here is my code: I blanked out the database connection info for security reasons
<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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)
*/
$aColumns = array( 'state', 'code' );

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "state";

/* DB table to use */
$sTable = "states";

/* Database connection information */
$gaSql['user'] = "";
$gaSql['password'] = "";
$gaSql['db'] = "";
$gaSql['server'] = "localhost";

/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
//include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/

/*
* MySQL connection
*/
$gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) or
die( 'Could not open connection to server' );

mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
die( 'Could not select database '. $gaSql['db'] );

mysql_set_charset('utf8');


/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}


/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    When I look at the document, it looks like it is returning sEcho:1, but its doing it in an HTML wrapper:

    [code]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">







    Untitled 1



    {"sEcho":1,"iTotalRecords":"72","iTotalDisplayRecords":"72","aaData":[["Alabama","AL"],["Alaska","AK"],["Alberta","AB"],["American Samoa","AS"],["Arizona","AZ"],["Arkansas","AR"],["British Columbia","BC"],["California","CA"],["Colorado","CO"],["Connecticut","CT"]]}


    [/code]

    That is obviously not valid JSON :-)

    Allan
  • cmandelacmandela Posts: 2Questions: 0Answers: 0
    OK Thanks then how do I fix it????
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    No idea! :-)

    I've never used FrontPage before so I'm not going to be much help there I'm afraid. You'd be best off asking in a FrontPage discussion forum.

    Allan
This discussion has been closed.