如何在我的PHP文件中解决以下解析错误?

时间:2015-12-10 19:37:31

标签: php

我使用以下PHP代码。

<?php

$inputuser = $_POST["username"];
$inputpass = $_POST["password"];

$user = "root";
$password = "";
$database = "data";

$connect = mysql_connect("localhost",$Username,$Password);
@mysql_select_db($database) or ("Invalid");

$queryuser = " SELECT * FROM `users` WHERE `Username` = '$inputuser' '';
$querypass = " SELECT * FROM `users` WHERE `Password` = '$inputpass' '';

$resultuser = mysql_query($queryuser);
$resultpass = mysql_query($querypass);

$rowuser = mysql_fetch_array($resultuser);
$rowpass = mysql_fetch_array($resultpass);

$serveruser = $rowuser["Username"];
$serverpass = $rowpass["Password"];

if ($serveruser && $serverpass) 
{
if (!$resultuser)
{
die ("Invalid.");
}
echo "Invalid.";
mysql_close();
if ($inputpass == $serverpass)
{
echo "Welcome.";
header('location: home.php');
}
else
{
echo "Invalid.";
header('location: fail.php');
}
}

?>

我一直收到以下错误。

Parse error: syntax error, unexpected 'SELECT' (T_STRING) in C:\Xampp\htdocs\login.php on line 14

我使用MySQL数据库和一些其他HTML文件与此代码。我检查过拼写错误和符号错误。我没有找到任何,但这个问题一直在发生。请帮忙。

1 个答案:

答案 0 :(得分:0)

您的查询应该是

$queryuser = " SELECT * FROM `users` WHERE `Username` = '$inputuser' ";
$querypass = " SELECT * FROM `users` WHERE `Password` = '$inputpass' ";