Click here to Skip to main content
15,921,716 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
( ! ) Parse error: syntax error, unexpected ':' in E:\wamp\www\my own\checklogin.php on line 11

PHP
<?php
    session_start();
    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $bool = true;

    mysql_connect("localhost", "root", "") or die (mysql_error()); //Connect to server
    mysql_select_db("first_db") or die ("Cannot connect to database"); //Connect to database
    $query = mysql_query("Select * from users WHERE username='$username'"); // Query the users table
    $exists = mysql_num_rows($query); //Checks if username exists
    $users = "":
    $password = "";
    if($exists > 0) //IF there are no returning rows or no existing username
    {
       while($row = mysql_fetch_assoc($query)) // display all rows from query
       {
          $users = $row['username']; // the first username row is passed on to $table_users, and so on until the query is finished
          $password = $row['password']; // the first password row is passed on to $table_password, and so on until the query is finished
       }
       if(($username == $users) && ($password == $password))// checks if there are any matching fields
       {
          if($password == $password)
          {
             $_SESSION['user'] = $username; //set the username in a session. This serves as a global variable
             header("location: home.php"); // redirects the user to the authenticated home page
          }
       }
       else
       {
        Print 'alert("Incorrect Password!");'; // Prompts the user
        Print 'window.location.assign("login.php");'; // redirects to login.php
       }
    }
    else
    {
        Print 'alert("Incorrect username!");'; // Prompts the user
        Print 'window.location.assign("login.php");'; // redirects to login.php
    }
?>


What I have tried:

i also paste the code in which this error exist. plz correct it
Posted
Updated 18-Feb-18 20:07pm
v2

1 solution

You used a : instead of ;
$users = "";
 
Share this answer
 

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