通常情况下,T_String错误是在有额外引用时,或者至少我认为。今晚我收到了这个错误
Parse error: syntax error, unexpected T_STRING in /var/www/html/registerBackend.php on line 118
这是第118 + 119行的代码
$query = "INSERT INTO User (Name,Email,Password,Port) VALUES ('$name', '$email','$password','$port')";
mysql_query($query) or die('Error, insert query failed');
如果有帮助,可以使用以下代码
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname ='hidden';
mysql_select_db($dbname);
//Check if Username has been used before
$query = "SELECT * FROM User where Name='$name'";
$result=mysql_query($query) or die('Error, insert query failed');
$countName=mysql_num_rows($result);
//Check if email has been used before
$query = "SELECT * FROM User where Email='$email'";
$result=mysql_query($query) or die('Error, insert query failed');
$countEmail=mysql_num_rows($result);
if($countName < 1 && $countEmail < 1){
//Assign their port number
$query = "SELECT * FROM login;
$countPort=mysql_num_rows($result);
$port = 20000 + $countPort;
$query = "INSERT INTO User (Name,Email,Password,Port) VALUES ('$name', '$email','$password','$port')";
mysql_query($query) or die('Error, insert query failed');
$query = "SELECT username, password FROM login WHERE username = '$username' AND password = '$password'";
$result = mysql_query($query);
print "<center><div id=newAREA>You have been signed up!<br>";
while($row = mysql_fetch_array($result, MYSQL_ASSOC)){
echo "Minecraft Username:{$row['Name']} <br>" .
"Email:{$row['Email']} <br>" .
"Password:{$row['Password']} <br>".
"Port:{$row['Port']} <br>";
}
} elseif ($countName > 1) {
print "Someone has already used this Minecraft IGN! E-mail Stolen@freeminecrafthost.com to prove it is yours!";
} elseif ($countEmail > 1) {
print "Email has been used before!";
}
答案 0 :(得分:2)
尝试
$query = "INSERT INTO User (Name,Email,Password,Port) VALUES ('" . mysql_real_escape_string($name) . "', '" . mysql_real_escape_string($email) . "','" . mysql_real_escape_string($password) . "','" . mysql_real_escape_string($port) . "')";
mysql_query($query) or die('Error, insert query failed');
<强>更新强>
这一行
$query = "SELECT * FROM login;
应该是
$query = "SELECT * FROM login";
答案 1 :(得分:1)
//Assign their port number
$query = "SELECT * FROM login;
$countPort=mysql_num_rows($result);
$port = 20000 + $countPort;
您在login
之后错过了引用。
$query = "SELECT * FROM login";
赞美,语法高亮!
答案 2 :(得分:0)
在线:
$query = "SELECT * FROM login;
你需要:
$query = "SELECT * FROM login";
但绝对需要给这些查询一些爱。