[phplib] How to test mysql_query return code properly with php4 ? From: Thomas CARRIE (Thomas.Carrie <email protected>)
Date: 08/16/00

mysql_query is supposed to return TRUE when your query succeeded,
so that's why you can find the following code in phplib :

    $this->Query_ID =  <email protected>($Query_String,$this->Link_ID);
    $this->Row = 0;
    $this->Errno = mysql_errno();
    $this->Error = mysql_error();
    if (!$this->Query_ID) {
        // error

It seems that FALSE is return when my query return no row,
so I get an error message despite the query is correct

Example that doesn't works :

If Query_String is
update active_sessions set val='RXhg..', changed='224..' where sid='0ea...' and name='Example_Session'

then Query_ID is not 'printable' (echo Query_ID print nothing)
and I get an 'empty' error message (mysql_error() contains nothing)

Example that works :

if Query_String is
select val from active_sessions where sid = '0ea1...' and name = 'Example_Session'

then Query_ID is
Resource id #2

I run phplib-7.2b on PHP 4.0.1 Release Candidate 2 and MySql 3.22

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>