1 (edited by tester1 05/22/2014 07:03:37 am)

Topic: Navigation : Sorting by ( ASC / DESC )

Hi,

I have my custom page where i am using db_pager functionality .. in this i have used asc /desc feature that's 'ord'=>'' , when i click my column name for asc / desc then i get sql error message .. and in that order by "" is blank ... where as same code is working well in my localhost pc..

//=======================

function get_test () {

   
       $sql = "SELECT id,name,datetime FROM ".TB_PREF."test_table ";   
       
       return $sql;
       
}

//=======================

$result = get_test();

$cols = array(
        _("ID")=>array('align'=>'center','ord'=>''),
        _("Test name ")=>array('align'=>'center','ord'=>''),
        _("Added Date")=>array('align'=>'center'),
        ' '=> array('insert'=>true, 'fun'=>'select_link'),
        array('insert'=>true, 'fun'=>'edit_link'),
        array('insert'=>true, 'fun'=>'del_link'));

    if (!@$_REQUEST['popup']) {
        $cols[' '] = 'skip';
    }
       
$table =& new_db_pager('test_table', $result, $cols);
$table->width = "95%";
display_db_pager($table);

//=================================================

when i click on "Test name" column for asc/desc  i am getting message

"//-----

DATABASE ERROR : Error browsing database: SELECT id,name,datetime FROM ".TB_PREF."test_table  ORDER BY LIMIT 0, 10
error code : 1064
error message : 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 'LIMIT 0, 10' at line 1
sql that failed was : SELECT id,name,datetime FROM ".TB_PREF."test_table ORDER BY LIMIT 0, 10

---//"

Hence i got to know that ORDER BY " "  is blank .. why so can any one tell me... ? is missing .. i have included all file that's
include($path_to_root . "/includes/db_pager.inc");
include($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/date_functions.inc");

Note : as i said ...i am able to do "asc/desc"  in my local host ...but getting error message in my online server .. pls help me

Re: Navigation : Sorting by ( ASC / DESC )

It's strange the same code won't work if it's work on your local. Is there any information you can give about the server? Maybe you can give me you snippet code to check if it has any error.

3 (edited by tester1 05/23/2014 05:32:32 am)

Re: Navigation : Sorting by ( ASC / DESC )

Hey Barbarian,

Thanks for reply bro,

Below are my code :

test.php

<?php
/**********************************************************************
test.php
***********************************************************************/
$page_security = 'SA_TESTENTRY';
$path_to_root = "..";

include($path_to_root . "/includes/db_pager.inc");

include($path_to_root . "/includes/session.inc");

page(_($help_context = "Manage Test"),@$_REQUEST['popup']);

include_once($path_to_root . "/includes/ui.inc");

include_once($path_to_root . "/includes/date_functions.inc");

include_once($path_to_root . "/testsarea/test_db.inc");

simple_page_mode(true);

//-------------------------------------------------------------------------------------------------


function can_process()
{


     if (strlen($_POST['testname']) == 0)
    {
        $input_error = 1;
        display_error( _("Please   name cannot be empty."));
        set_focus('testname');
       return false;
        
    }

    return true;
}

function edit_link($row) {
       
       return button("Edit".$row["id"],_("Edit"), '', ICON_EDIT);
        }
}

function del_link($row) {
         
       return button("Delete".$row["id"],_("Delete"), '', ICON_DELETE);
        }      
}

function select_link($row) {
    return button("Select".$row["id"], $row["id"], '', ICON_ADD, 'selector');
}


               
//-------------------------------------------------------------------------------------------------


if ($Mode=='ADD_ITEM'){
   
    if (can_process()){
     
            add_namelist($_POST['testname']);
            display_notification_centered(_("The details has been added."));
            $Mode = 'RESET';
                       
                       
        }
       
}


//-------------------------------------------------------------------------------------------------
if ($Mode == 'RESET'){
   
    $selected_id = -1;
    $sav = get_post('show_inactive');
    unset($_POST);    // clean all input fields
    $_POST['show_inactive'] = $sav;
}



start_form();

start_outer_table(TABLESTYLE2, "width=80%");

table_section(1);
ref_cells(_("name:"), 'name_search', '',null, '', true);

table_section(2);
submit_cells('Search', _("Search"),'',_('Search Kapan'), 'default');

end_outer_table(); // outer table



$result = get_test(get_post('name_search'));

$cols = array(
        _("ID")=>array('align'=>'center','ord'=>''),
        _("Test name ")=>array('align'=>'center','name'=>'testname','ord'=>''),    // i tried even with name=>'fieldname'  -- local working , but on my server its not working
        _("Added Date")=>array('align'=>'center'),
        ' '=> array('insert'=>true, 'fun'=>'select_link'),
        array('insert'=>true, 'fun'=>'edit_link'),
        array('insert'=>true, 'fun'=>'del_link'));

    if (!@$_REQUEST['popup']) {
        $cols[' '] = 'skip';
    }
       
$table =& new_db_pager('test_table', $result, $cols);
$table->width = "95%";
display_db_pager($table);

echo '<br \ >';

//-------------------------------------------------------------------------------------------------
start_table(TABLESTYLE2);

if ($selected_id != -1)
{
      if ($Mode == 'Edit') {
        //editing an existing User
        $myrow = get_namelisting($selected_id);
        $_POST['id'] = $myrow["id"];
        $_POST['testname'] = $myrow["testname"];

    }
    hidden('selected_id', $selected_id);
    hidden('id');
    start_row();
    
}

textnumber_cells(_("Name: "), 'testname',NULL,'',4);

end_table(1);

submit_add_or_update_center($selected_id == -1, '', 'both');

end_form();

end_page(@$_REQUEST['popup']);

?>

//----




test_db.php





function add_namelist($name)
{
   
        $added_date = myowndate();
          $sql = "INSERT INTO ".TB_PREF."test_table (testname, datetime)
        VALUES (".db_escape($name).", ".db_escape($added_date).")";

        return db_query($sql, "could not add details for $name");
}


//===============


function get_test ($name = '') {
      $sql = "SELECT id,testname,datetime FROM ".TB_PREF."test_table WHERE 1=1 ";   
     
      if($name){
              $sql .= " AND testname LIKE ". db_escape("%$name%");
      }
      
      return $sql;
}


//-----


function get_namelisting($id)
{
        $sql = "SELECT * FROM ".TB_PREF."test_table WHERE id=".db_escape($id);

        $result = db_query($sql, "could not get details $id");
   
        return db_fetch($result);
}


//

pls have look on above code .. i dont have option to upload any file , hence puted all code here.. waiting

Re: Navigation : Sorting by ( ASC / DESC )

any one here ..pls help .. admin ..any one

Re: Navigation : Sorting by ( ASC / DESC )

Sorry, I just can't answer because your code is looking good. Even in your local is working. Maybe it's because the different version of MySQL in the server or anything. You must test in another machine.

Re: Navigation : Sorting by ( ASC / DESC )

admin pls help me .. this custom  page is impt ..hence pls let me know ..what is missing plss

Re: Navigation : Sorting by ( ASC / DESC )

Like Barbarian, we have no idea. While it works in your local Environment but not on your server.
Please goto Setup tab, run System Diagnostics in both Environments and give us a link or upload the pictures.
This will tell us a Little more.

/Joe

8 (edited by tester1 06/02/2014 10:41:25 am)

Re: Navigation : Sorting by ( ASC / DESC )

Hi,

Thanks for reply .

Please find below link for system details : http://shashib.webege.com/system/

9 (edited by tester1 06/02/2014 11:22:57 am)

Re: Navigation : Sorting by ( ASC / DESC )

hey i show This system file to my server main .. and they did all green ..except :

MySQL version >=4.1    Required        Upgrade MySQL server to version at least 4.1

means all is " OK " + green .. ONLY

MySQL version >=4.1    Required        Upgrade MySQL server to version at least 4.1   --- RED

AND SORTING IS STILL NOT WORKING sad

Re: Navigation : Sorting by ( ASC / DESC )

There seems to be no MySql running on the server.
Also make the required folders writable.

Joe

11 (edited by tester1 06/03/2014 05:56:12 am)

Re: Navigation : Sorting by ( ASC / DESC )

Hey Joe,

Thanks for reply.

Yes all folder are writable.

Also " no mysql runnung on the server ": if on my server there is no mysql running then how could i run all my statement till now.

still not able to sort

Re: Navigation : Sorting by ( ASC / DESC )

The files should also be writable.

If you have access to the server phpMyAdmin, then open your database and in the SQL form, place the following:
SELECT VERSION() and run.

This will retrieve your MySql version.

/Joe

Re: Navigation : Sorting by ( ASC / DESC )

Yes file and folder all are writable ..


and as said : SELECT VERSION()  , its showing me : " 5.5.36-cll "

please let me know

thanks

Re: Navigation : Sorting by ( ASC / DESC )

Ok, now we know that. There have been some problems with this release.

Please try to download the mysql error log file. If we are lucky we can probably see some errors here.

Are you running the latest release of FA? 2.3.21? If not try to upgrade as well.

Joe

15 (edited by tester1 06/03/2014 08:44:11 am)

Re: Navigation : Sorting by ( ASC / DESC )

Hey Joe,

Can u guide me how i can download mysql error log file and from where.

Also before move on.. can you please take my above code and test from your end .. also in some page i have used JOIN Query.

No i am not using Latest version . I think its 2.3.16 or 2.3.17


It would be difficult for me to Upgrade to latest version .. as i have modify many includes / files .. and some core file to.

If particular sort - db_page  file can be replace then please let me know which which file i need to replace for update.

But working fine @ my localhost

Re: Navigation : Sorting by ( ASC / DESC )

Unfortunately I have no resources to help you further.

Please download a fresh installation from Sourceforge, and upload this to your server.

Make an install and see if you still have problems.

If so, something is not working correctly on your server.

Joe

Re: Navigation : Sorting by ( ASC / DESC )

Thanks JOE, for your great support till end .. will try to update to latest version and check if its working or not ..else my bad luck smile


thanks

18 (edited by tester1 11/01/2014 12:15:14 pm)

Re: Navigation : Sorting by ( ASC / DESC )

Hi,

After using https://frontaccounting.com/punbb/viewtopic.php?pid=21291
Mysqli ...my table sorting by asc/desc  is not working

which is because of

function db_field_name($result, $n)
{
    //return mysql_field_name($result, $n);
       $fieldinfo = mysqli_fetch_field_direct($result, $n);
        return $fieldinfo->name;
    
    
}

and if i click on sorting asc or desc then

"//-----

DATABASE ERROR : Error browsing database: SELECT id,name,datetime FROM ".TB_PREF."test_table   ORDER BY ,  LIMIT 0, 10
error code : 1064
error message : 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 'LIMIT 0, 10' at line 1
sql that failed was : SELECT id,name,datetime FROM ".TB_PREF."test_table ORDER BY LIMIT 0, 10

---//"



see ORDER BY , 

i think field name is not coming here ...


and after long time i found the prb .. i dont know its in that function or not but when i replace all mysql to mysqli as per above code my asc desc stop working .. any idea ???

Re: Navigation : Sorting by ( ASC / DESC )

if there were any mysqli, then it would become mysqlii....

Re: Navigation : Sorting by ( ASC / DESC )

i am using mysqli ...

what u means it would have become mysqlii ...

can u please help me

Re: Navigation : Sorting by ( ASC / DESC )

When you did a search and replace of mysql with mysqli, all existing (previously manually changed) mysqli would have become mysqlii ....

Re: Navigation : Sorting by ( ASC / DESC )

no i haven't search and replace  ... i have done manually

and btw we have to do just in one single page and thats " includes/db/connect_db.inc "  so there is no such issue of mysqli becoming mysqlii