解析错误:语法错误,意外的$结束
我收到以下错误解析错误:语法错误,意外的$ end在/home/test/login_success.php在第20行
继承我的代码
<?php
$host="mysql.website.com"; // Host name
$username="userma,e"; // Mysql username
$password="passwrd1"; // Mysql password
$db_name="mbs_orderstatus"; // Database name
$tbl_name="mbs_users"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// username and password sent from form
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
// To protect MySQL injection (more detail about MySQL injection)
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
$result=mysql_query($sql);
$data=mysql_fetch_assoc($result);
$_SESSION['username'] = $data['username'];
$_SESSION['status'] = $data['status'];
// 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";
}
?>
任何人有任何建议为什么会发生这种情况
编辑**
错误的文件,今天我太累了
// Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
<?php
session_start();
if(!session_is_registered(myusername)){
header("location:main_login.php");
echo $_SESSION['status'];
?>
<html>
<body>
Login Successful
</body>
</html>
有时候,它似乎也是因为一个短标签"<?"
如果您关闭了短标签!
在第二个粘贴的文件中,在调用头函数后缺少a }
。
注意:您的代码充满了SQL注入并使用了不推荐的功能。 请阅读有关它们。
链接地址: http://www.djcxy.com/p/69805.html