php - Wrong part of the if statement is executing -


$sth = $dbh -> prepare( "select * table id = :id" ); $sth -> bindparam( ':id', $_session['id'], pdo::param_int, 4 ); $sth -> execute(); $result = $sth -> fetch();  if( isset( $result["id"] ) ) {     // if records returned } else {     // if no records returned } 

for reason, first part of if statement executes if no records returned, why happening? i'm assuming it's because of isset, don't know change too?

try replacing this

  if ($sth->rowcount() > 0) {    } else {    }  

http://php.net/manual/en/pdostatement.rowcount.php


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -