in reply to Don't understand row

Is $sth2 supposed to be spelled $sth? If not, you need to show some different code.

In general, you should be using placeholders instead of interpolating values into the SQL text. You are certain to run into quoting difficulties without them. That could be another source of trouble for you.

The rows method of a statement handle is not really meant to be used with select. Expect odd results.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Don't understand row
by Anonymous Monk on Feb 14, 2005 at 05:06 UTC
    Ok, It was supposed to be $sth. But I don't understand this statement "if($sth->rows() <= 0)".

    After fixing all those simple error, I add this code to test it "else{...." and the output is from the else{... where it should be from the if(.....

    sorry for my english.

    Thanks

      DBI's rows method is supposed to return the number of rows affected by the sql statement after it is executed. That is only meant to work with table-modifying statements, but some drivers may return good results for selects as well.

      That you are seeing the comparison fail means you are getting a positive number from rows. That is what you would expect for a successful query, assuming select $sth's rows works.

      After Compline,
      Zaxo