Parse error: syntax error, unexpected $end
I am getting the following error Parse error: syntax error, unexpected $end in /home/test/login_success.php on line 20
heres my code
<?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";
}
?>
Anybody have any suggestions why this occurs?
EDIT**
wrong file, im a bit too tired today aha
// 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>
Sometimes it also seems to be because of a short tag "<?"
if you have short tags turned off!
In the second pasted file, a }
is missing after the header function call.
Note: your code is full of SQL injection and use of deprecated functionality. Please read about them.
链接地址: http://www.djcxy.com/p/69806.html上一篇: 解析错误:语法错误,文件意外结束
下一篇: 解析错误:语法错误,意外的$结束