in reply to Re^12: CGI Action call
in thread CGI Action call

Thanks

That query param contains only Dare, not Dare\".

Removed the calls to alter table and it works Ok and faster except for the same problem with navigating to previous record

I copy the SQL from the DBI which failed and past into php MyAdmin SQL and it works fine.

Do not understand why the difference

Replies are listed 'Best First'.
Re^14: CGI Action call
by poj (Abbot) on Mar 29, 2018 at 14:08 UTC
    That query param contains only Dare, not Dare\".

    Why then does your log say rowpointer = 'Dare"'

    [Wed Mar 28 15:18:59 2018] update_tables.cgi: rowpointer = 'Dare"' at 003: +update_tables.cgi line 292.
    Removed the calls to alter table

    How are you persisting the sort order variable $sortindex between calls to search_Records() and navigate_Records() ?. You appear to be using the same parameter name kind for sort order in search_Records() and movement direction in navigate_Records(). Why not create another parameter for movement direction and then persist the sort order with it's own parameter.

    poj

      rowpointer = 'Dare"'

      It does indeed

      In php MyAdmin previous (<-) SQL the \" causes the command to just reload the Dare record. Removing the \" from the SQL allows it to fuction property.

      However, in the next (->) SQL the next record is sent to the client as expected with or without removing the \".

      Very strange

      No \" after Dare

      Found problem buried in javascript. Fixed.

      Thanks. Still doesn't shed light on why -> works and <- doesn't with the \" after the lastname.

        why -> works and <- doesn't

        Because although the correct surname is 'Dare' your sql is using 'Dare"'. The next record to 'Dare"' will be 'Ebert', the " makes no difference. The previous record to 'Dare' using the sql  < 'Dare"' will be 'Dare' so it becomes stuck

        Looking at the code you posted Re^6: CGI Action call

        #Last record Tested Good $stmt = "SELECT * FROM ( SELECT * FROM users WHERE $searchfield <= ? AND $searchfield >= ? ORDER BY $searchfield DESC LIMIT 1 ) sub ORDER BY $searchfield ASC"; #example lastname SELECT * FROM ( SELECT * FROM users WHERE lastname >='z%' AND lastname >= 'a%' ORDER BY user_id DESC LIMIT 1 ) sub ORDER BY lastname ASC #Works fine hard coded

        The hard coded version has a mistake with >='z%' which should be <= as in the $stmt. Correcting that mistake would give you

        SELECT * FROM ( SELECT * FROM users WHERE lastname <='z%' AND lastname >= 'a%' ORDER BY user_id DESC LIMIT 1 ) sub ORDER BY lastname ASC

        But, if you think that works correctly then add the name 'Ryan Zimmerman' to you user table and try navigating to last record. Then try the simpler

        SELECT * FROM users ORDER BY lastname DESC LIMIT 1

        Whilst this is SQL and not perl, applying the KISS_principle to both makes bugs more easily tracked down.I suspect there are more depending on how you are persisting the sort order between cgi calls

        poj