Click here to Skip to main content
14,875,778 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\xampp\htdocs\Traffic_Reports\login.php on line 17

PHP
<?php
session_start();
include("Includes/header.php");
include("functions.php");
connect();

if(isset($_POST['login'])){
    if(isset($_SESSION['uid'])){
        echo "You are already logged in!";
    }else{
        $name = protect($_POST['name']);
        $password = protect($_POST['password']);

        $login_check = mysql_query("SELECT 'id' FROM 'user' WHERE 'name'='$name' AND 'password'='".md5($password)."'") or die(mysql_error());
        if(mysql_num_rows($login_check) == 0) {
            echo "invalid Name or Password Combination!"
        }else{
            $get_id = mysql_fetch_assoc($login_check);
            $_SESSION['uid'] = $get_id['id'];
            header("Location: main.php");
        }
    }
}else{
    echo "You have visited this page incorrectly!";
}

?>
Posted

Just add a comma semi-colon (;) after echo "invalid Name or Password Combination!"
C#
<?php
session_start();
include("Includes/header.php");
include("functions.php");
connect();
 
if(isset($_POST['login'])){
    if(isset($_SESSION['uid'])){
        echo "You are already logged in!";
    }else{
        $name = protect($_POST['name']);
        $password = protect($_POST['password']);
 
        $login_check = mysql_query("SELECT 'id' FROM 'user' WHERE 'name'='$name' AND 'password'='".md5($password)."'") or die(mysql_error());
        if(mysql_num_rows($login_check) == 0) {
            echo "invalid Name or Password Combination!";  // add semi-colon here
        }else{
            $get_id = mysql_fetch_assoc($login_check);
            $_SESSION['uid'] = $get_id['id'];
            header("Location: main.php");
        }
    }
}else{
    echo "You have visited this page incorrectly!";
}
 
?>
   
v3
Hi,

your Error is on the following line that is you missed the ';'

echo "invalid Name or Password Combination!";
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900