i test whether entry of particular uid , mid exists in table user_saved, here's did
$result = $db->prepare("select * user_saved uid = ? , mid = ?"); $result->execute(array($_session['uid'], $itemid['mid2'])); $test = $result->fetch(pdo::fetch_assoc); if (isset($test)){ exist } else { doesn't exist }
the issue tried uid , mid doesn't exist, goes isset if statement, why this? what's better way this?
isset checking whether variable exists or not use strlen function or array count function
<?php $bbnq = sprintf("select login users id = %u",27); try { $req = $db_bbn->query($bbnq); } catch (exception $e) { bbnf_pdo_error($e,__file__,__line__); } if ( $r = $req->fetch() ) { echo "this query has row result"; } else { echo "this query has empty result"; } ?>
Comments
Post a Comment