gpt4 book ai didi

php - 找不到意外的 T_STRING

转载 作者:行者123 更新时间:2023-11-29 06:08:34 26 4
gpt4 key购买 nike

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

最佳答案

尝试

$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";

关于php - 找不到意外的 T_STRING,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10264797/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com