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 { }
Comments
Post a Comment