PHP解析错误:语法错误,意外' $ _ GET' (T_VARIABLE)

时间:2017-07-01 11:28:00

标签: php mysql database url url-parsing

首先,是的,我已经做过研究,并且看过很多这样的帖子。我看到这个帖子应该是重复的,但它没有帮助。我对此很新,不知道如何将结果应用到我的。 运行时我得到了这个结果:

Parse error: syntax error, unexpected '$_GET' (T_VARIABLE) in /storage/ssd4/269/2113269/public_html/updateuser.php on line 12

这是我的剧本:

<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
            $sql = "UPDATE Users ". "SET Status = '"$_GET["status"]"' ".
               "WHERE Username = '"$_GET["username"]"'";
if ($conn->query($sql) === TRUE) {
    echo "Record updated successfully";
} else {
    echo "Error updating record: " . $conn->error;
}

$conn->close();
?>

谢谢你们一起来看看。我可能在某个地方错过了一个分号,但我已经查看了一段时间的代码。请让我知道!

3 个答案:

答案 0 :(得分:2)

您必须使用$sql = "UPDATE Users ". "SET Status = '".$_GET["status"]."' ". "WHERE Username = '".$_GET["username"]."'";

连接字符串
{{1}}

答案 1 :(得分:1)

您需要//struct for cpu struct CPU_Player { CPU_Player(int n) : number(n){ } DWORD BaseAddress; const int number; vector<float> coordinates = { 0, 0, 0 }; char team[8] = { 0 }; int health; void read_Memory() { //get current player baseaddress DWORD temp; READ_WRITE_SUCCESS = ReadProcessMemory(process, sauerbratenexe + Offset_CPUBase/sizeof(DWORD), &temp, sizeof(DWORD), 0); ReadProcessMemory(process, (DWORD*)(temp + Offset_CPUBase_2*(number+1)), &BaseAddress, sizeof(DWORD), 0); //ReadProcessMemory(process, (DWORD*)(temp + Offset_CpuPlayer*number), &BaseAddress, sizeof(DWORD), 0); cout.setf(ios_base::hex, ios_base::basefield); cout << BaseAddress << endl; //get health ReadProcessMemory(process, (DWORD*)(BaseAddress + Offset_Health), &health, sizeof(int), 0); //get xyz ReadProcessMemory(process, (DWORD*)(BaseAddress + Offset_Position_x), &coordinates[0], sizeof(float), 0); ReadProcessMemory(process, (DWORD*)(BaseAddress + Offset_Position_y), &coordinates[1], sizeof(float), 0); ReadProcessMemory(process, (DWORD*)(BaseAddress + Offset_Position_z), &coordinates[2], sizeof(float), 0); //team ReadProcessMemory(process, (DWORD*)(BaseAddress + Offset_TeamName), &team, 8, 0); } };vector<CPU_Player*> cpu_players; concatenatestring正确使用variable

dot(.)

答案 2 :(得分:0)

这是因为您在"语句声明之前和之后以GET结束并启动语句;但是没有将."之间的串联GET放在一起。

"SELETCT tb FROM db WHERE field = '".GET ['something']."'";

GET语句中包含两个IF并在机器人Get具有某些值时运行完整代码也是一个好习惯。减少不必要的SQL和PHP执行。