这是什么类型的错误? Plz在以下代码中对其进行了核心处理。 [英] What type of error is this? Plz coreect it in the following code.
本文介绍了这是什么类型的错误? Plz在以下代码中对其进行了核心处理。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(!)解析错误:语法错误,第11行的E:\ wamp \\\\ my own\checklogin.php意外':'
( ! ) Parse error: syntax error, unexpected ':' in E:\wamp\www\my own\checklogin.php on line 11
<?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
}
?>
我的尝试:
i还会粘贴存在此错误的代码。 plz更正
What I have tried:
i also paste the code in which this error exist. plz correct it
推荐答案
用户名 = mysql_real_escape_string(
username = mysql_real_escape_string(
_POST [' 用户名']);
_POST['username']);
密码 = mysql_real_escape_string(
password = mysql_real_escape_string(
这篇关于这是什么类型的错误? Plz在以下代码中对其进行了核心处理。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文