第6行的PHP解析错误...似乎很喜欢它我想要的东西很简单。

时间:2012-11-16 02:20:40

标签: php sql

我在创建简单登录表单时遇到问题。任何人都可以解释为什么SQL在第6行的C:\ xampp \ htdocs \ Easy Grade 2000 \ login.php中说“解析错误:语法错误,意外'$ username'(T_VARIABLE)”以及如何修复它?

由于

<?php

include 'connect.php'

// username and password sent from form 
$username = $_POST['u_name']; 
$password = $_POST['p_word']; 

$sql="SELECT * FROM $db_name WHERE u_name='$username' and p_word='$password'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row

if($count==1){
// Register $myusername, $mypassword and redirect to file "login_success.php"
session_register("myusername");
session_register("mypassword"); 
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>

1 个答案:

答案 0 :(得分:2)

你忘记了分号后的分号:

include 'connect.php';
                     ^---- :)