mrna3r
mrna3r

Reputation: 11

Why pdo doesn't work for queries that's have space character?

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

Answers (1)

BlitZ
BlitZ

Reputation: 12168

  1. isset() returns boolean;
  2. you combining 2 separate operations in your if(), try boolean logic operators and or or to summarize;
  3. 'hello you' != 'admin' so it's resulting echo 'false';

Try this:

if (!isset($privilegien) || ($privilegien !== "admin")){echo"false";exit;}

Upvotes: 3

Related Questions