0

通常,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!";
}
4

3 回答 3

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";
于 2012-04-22T02:57:30.907 回答
1
//Assign their port number
$query  = "SELECT *  FROM login;
$countPort=mysql_num_rows($result);
$port = 20000 + $countPort;

您在 之后缺少报价login

$query  = "SELECT *  FROM login";

赞美,语法高亮!

于 2012-04-22T02:59:34.243 回答
0

在线的:

$query  = "SELECT *  FROM login;

你需要有:

$query  = "SELECT *  FROM login";

但肯定也需要对这些问题提出一些热爱。

于 2012-04-22T02:58:15.723 回答