server side displaying only when I input something in search

server side displaying only when I input something in search

pjarospjaros Posts: 3Questions: 0Answers: 0
edited April 2010 in General
Hi
First of all great thanks to Allan. I can only say Wow! about DataTables.
I display data with server side processing in php:

[code]session_start();
include('inc/polaczenie.inc');

/* Paging */
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_GET['iDisplayStart'] ).", ".
mysql_real_escape_string( $_GET['iDisplayLength'] ).";";
}

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

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi PJ,

    So this works normally, but you only get an error when you add a search query? Is there any chance you are able to provide a link to this so I can see it in action? What is the JSON return when it does error? And also, there is a "//echo $sQuery;" in the code - what is $sQuery when there is an error?

    Thanks!
    Allan
  • pjarospjaros Posts: 3Questions: 0Answers: 0
    Hi Allan,

    thx for fast response.
    I can't provide link for now cause i work on localhost but if I won't solve it soon I'll put somwhere in the net.
    Basicly it shows only thead part with length, paginating and search input and column names. There is no data. If i put for example 'as' in input box it shows all the records with 'as' string in it and shows info that Showing 1 to 3 of 3 entries (filtered from 17 total entries) which is right cause i have 17 records in database.

    When i display serverside file it shows me text in validate json format (i checked in validator).
    Query works in phpmyadmin and it is:
    [code]SELECT SQL_CALC_FOUND_ROWS `Nazwa`,`Opis`,`Imie`,`Nazwisko`,`Imie2`,`Imie3`,`Wiek`,`Zdjecie`,`Data urodzenia`,`jedenasty`,`Testowy kwiecien` FROM dane [/code]

    I've checked many things and I may have something wrong with css which is a little bit messy or other js libraries are incompatible. This is what I include:
    [code]


    google.load("jquery", "1.3.2");
    google.load("jqueryui", "1");







    [/code]

    If you have any other question I'm still here.
    Apart from that I'm going to base on your product in some commercial projects and I'm really intrested to cooperate a litle bit more.

    Best regards,
    PJ
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi PJ,

    Is that the full query? I guess you have pagination and sorting disabled in that case? But if it is returning what you expect in PhpMyAdmin, then it should be fine... Are you able to include the JSON output from the request with a search (http://datatables.net/contact if you don't want to make it public)? I don't see anything obviously wrong with the code - but there is certainly some issue somewhere... :-)

    Regards,
    Allan
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    For anyone encountering a similar problem - it would appear that the JSON return from PJ's server-side script was invalid due to a \n or \r in the middle of the JSON. Removing this does the trick.

    Allan
  • pjarospjaros Posts: 3Questions: 0Answers: 0
    thx a lot for help.

    if that may help i just put code which I added to server-side script:

    [code]
    $what= array("\n", "\r");
    $with="";
    $sOutput = str_replace($what, $with, $sOutput);
    [/code]
This discussion has been closed.