3

我在创建简单的登录表单时遇到问题。谁能解释为什么 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";
}
?>
4

1 回答 1

2

您忘记了包含后的分号:

include 'connect.php';
                     ^---- :)
于 2012-11-16T02:21:32.193 回答