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?

Answers


  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;}

Need Your Help

Symfony submitting individual forms on page with multiple forms

forms symfony include twig

My Symfony project consists of 3 bundles 2 of which provides forms.

Creating Falling Snow in AS3/Flash

actionscript-3 flash

So I am trying to create random, falling snow in a Flash application. Using the following code I have my snow appearing at a random point on the screen.