-3

Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\example\example2.php on line 23

My code looks like this: Exemplu Email

Password

    <?php
        $con= mysqli_connect("localhost","root","","amit");
        if(isset($_POST['login'])){
            $email= mysqli_escape_string($con, $_POST['email']);
            $password= mysqli_escape_string($con, $_POST['pass']);
            $select_user= "SELECT > FROM example WHERE Email='$email' AND Passwords='$password'";
            $run_user= mysqli_master_query($con , $select_user);
            $check_user= mysqli_num_rows($run_user);
            if($check_user > 0) {
                header('location:home.php')
            }else{echo "wrong username or password";
        }






        }
    ?>

What is the problem with it on line 23? (Line 23 is where the second if begins)

Dharman
  • 30,962
  • 25
  • 85
  • 135

3 Answers3

2

Missing ; in header('location:home.php')

It should be:

if($check_user > 0) {
    header('location:home.php');
    }else{
        echo "wrong username or password";
      }

Upadated:

Another Problem with SELECT > it should be SELECT *
Your Code:

$select_user= "SELECT > FROM example WHERE Email='$email' AND Passwords='$password'";

It should be:

$select_user= "SELECT * FROM example WHERE Email='$email' AND Passwords='$password'";

Comments Problem:

You have used mysqli_master_query() but This function is currently not documented; only its argument list is available. Please see the website doc.

Chonchol Mahmud
  • 2,717
  • 7
  • 39
  • 72
  • That was it! I can't believe I didn't put that there!I really appreciate your help! Thank you! – Vladut Maican Jul 14 '16 at 10:53
  • Please accept this an answer if it solved your issue. It helps future SO users. – Alok Patel Jul 14 '16 at 10:53
  • What about this one? It's saying about my num rows function. It's just a warning but it's there. Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\example\example2.php on line 20 – Vladut Maican Jul 14 '16 at 10:55
  • 1
    @Alok 12 minutes must have passed since I posted the question in order to accept any answer. I will as soon as I can. – Vladut Maican Jul 14 '16 at 10:56
  • @VladutMaican Awesome! – Alok Patel Jul 14 '16 at 10:58
  • @ChoncholMahmud How can I solve this good sir? Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\example\example2.php on line 20 – Vladut Maican Jul 14 '16 at 11:02
0

instead

header('location:home.php')

use

header('location:home.php');
0

Just use a semicolon after your header location line.

Also, I don't see a reason for this SELECT >

Try writing cleaner code.

 <?php
    $con = mysqli_connect("localhost","root","","amit") or die(mysqli_connect_error());

    if (isset($_POST['login'])) {

        $email    = mysqli_escape_string($con, $_POST['email']);
        $password = mysqli_escape_string($con, $_POST['pass']);

        $select_user = "SELECT * FROM example WHERE Email= '".$email."' AND Passwords='".$password."'";
        $run_user    = mysqli_query($con , $select_user) or mysqli_error($con); // 
        $check_user  = mysqli_num_rows($run_user);

       if ($check_user > 0) {
            header('location:home.php');
        } else {
           echo "wrong username or password";
        }
     }
  ?>

On a side note, using functions like mysqli_error and mysqli_connect_error really helps in debugging. You may wanna refer to these:

Simple mysqli set up

mysqli error functions

Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32
  • Thank you! What is this error tho'? Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\example\example2.php on line 20 – Vladut Maican Jul 14 '16 at 10:59
  • That's because your previous line has some SQL syntax error. I'm a bit skeptical about mysqli_master_query. Is there a reason why you can't use mysqli_query()?? – Indrasis Datta Jul 14 '16 at 11:08