Reputation: 11
I connect to database with PDO . But when i have variables with values that's have space character it doesn't show anything for me:
require_once('db.php');
$stmt = $dbConnection->prepare('SELECT * FROM db1_etchat_user WHERE etchat_username = :name and etchat_userpw = :pass');
$stmt->execute(array(':name' => $username,':pass' =>$password));
foreach ($stmt as $row){
$privilegien=$row['etchat_userprivilegien'];
}
if (!isset($privilegien)!=="admin"){echo"false";exit;}
if $privilegien
value have variable contains space character such as "hello you" it echo "false".
How I can resolve it?
Upvotes: 1
Views: 235
Reputation: 12168
isset()
returns boolean
;if()
, try boolean logic operators and
or or
to summarize;'hello you' != 'admin'
so it's resulting echo 'false'
;Try this:
if (!isset($privilegien) || ($privilegien !== "admin")){echo"false";exit;}
Upvotes: 3