-2

where is the problem? anyone tell me because line 17 code does not have a problem then why this error shows

Parse error: syntax error, unexpected 'if' (T_IF) in C:\xampp\htdocs\project\selected\adminlogincheck.php on line 17

<?php
session_start();

$con = mysqli_connect('localhost','root');
if($con){
echo " conection successful";
}else{
 echo"connection failed";
}
$db = mysqli_select_db($con, ' cbe schedular ');
if(isset($_POST['submit'])){
 $email= $_POST ['email'];
 $password = $_POST['password'];
 $sql =" select *from admin where email = '$email' and password ='$password'";
 $query = mysqli_query($con,$sql);
 $row = mysqli_num_rows(){
     if($row == true){
         echo"login susccessful";
         $_SESSION['user'] = $username;
         header('location : adminmainpage.php');
     }else{
        echo "login failed";
        header('location:adminlogin.php');
     }  
?>

after correction

    <?php
   session_start();

  $con = mysqli_connect('localhost','root');
 if($con){
        echo " conection successful";
}else{
    echo"connection failed";
}
$db = mysqli_select_db($con, ' cbe_schedular ');
if(isset($_POST['submit'])){
   $email= $_POST ['email'];
 $password = $_POST['password'];
 $sql =" select *from admin where email = '$email' and password ='$password'";
 $query = mysqli_query($con,$sql);
 $row = mysqli_num_rows();
     if($row == true){
         echo"login susccessful";
         $_SESSION['user'] = $username;
         header('location :../adminmainpage.php');
        }else{
                echo "login failed";
                header('location:adminlogin.php');
            }   
}

?> not redirect to adminlogin.php just show conection successful

1 Answers1

1

In PHP errors, it is important to look in the line preceeding the noted error.

In your case it says" unexpected 'if' (T_IF) in C:\xampp\htdocs\project\selected\adminlogincheck.php on line 17"

If we think logically the message is clear - UNEXPECTED, in otherwords, something has happened before this line which means that the IF statement in line 17 wasnt expected. The issue is therefore likely to be in line 16.

As the commentors have posted, you have the following line on 16

$row = mysqli_num_rows(){

This is not valid and your curly brackets have caused the issue, most likely you need to change this to a semi-colon.

Will
  • 389
  • 1
  • 11