Jump to content

unexpected T_BOOLEAN error


Darkranger85

Recommended Posts

Hey guys,

 

I'm having a problem with my code and am hoping that someone can help me narrow it down. The full error I get is as follows:

 

Parse error: syntax error, unexpected T_BOOLEAN_AND, expecting ')' in C:\wamp\www\testsite\login.php on line 9

 

Here is the code is question

 

<?php
    include 'core.inc.php';
    include 'connect.inc.php';
    session_start();
         
    $username = strip_tags(trim($_POST['user']));
    $password = strip_tags(trim($_POST['pass']));

    if(!empty($username&&$password)){
        mysql_select_db('adatabase') or die('Couldnt connect to db!');
    
        $query = mysql_query("SELECT * FROM users WHERE username='$username'");
        $numrows = mysql_num_rows($query);        
    
      if($numrows != 0){
            
         while ($row = mysql_fetch_assoc($query)){
              $dbusername = $row['username'];
              $dbpassword = $row['password'];
              $salt = $row['salt'];
              $password = crypt($password,$salt);
              $seclevel = $row['seclevel'];
          }
         
         if($seclevel > 1){
             die('Please activate your account before logging in.');
         }
         
         if ($username == $dbusername && $password == $dbpassword){
                echo "Welcome back! Click <a href='overview.php'>here</a> to proceed!";
                $_SESSION['username'] = $dbusername;                

         }else{
                echo "Incorrect username or password!";
         }
        
     }else{
            die ('Incorrect username or password!');
        }
    
    }else{
     die('Please enter a username and password!');
    }

?>

 

I've been staring at it all morning and I cant for the life of me figure out where a parenthesis is missing. I went down the code line by line and checked every single one to make sure it had a "mate" so to speak. And as for the unexpected "T_BOOLEAN" I have no idea lol.

 

Thanks for your help in advance!

Link to comment
https://forums.phpfreaks.com/topic/259692-unexpected-t_boolean-error/
Share on other sites

$username&&$password

That is the unexpected T_BOOLEAN

 

You cannot group together variables inside the empty function

You'll need to perform two of them... using that same T_BOOLEAN

 

if(  !empty($username)  &&  !empty($password)  )  {

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.