所以这是一个错误:
错误:
INSERT INTO fo_reports (`path`, `version`, `userContacts`, `userMessage`, `errorMessage`) VALUES (`asd`, `10`, `regtyh`, `frtgtyh`, `vfgtyh`)
未知列' asd'在'字段列表'
PHP文件本身:
<?php
$path = $_GET["path"];
$version = $_GET["version"];
$userContacts = $_GET["userContacts"];
$userMessage = $_GET["userMessage"];
$errorMessage = $_GET["errorMessage"];
$servername = "xxxxxxxxx";
$username = "xxxxxxxxxxx";
$password = "xxxxxxxxxxx";
$dbname = "xxxxxxxxxxxxxxxx";
$conn = mysqli_connect($servername, $username, $password, $dbname);
$sql = "INSERT INTO fo_reports (`path`, `version`, `userContacts`, `userMessage`, `errorMessage`) VALUES (`$path`, `$version`, `$userContacts`, `$userMessage`, `$errorMessage`)";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
?>
那我怎么解决这个问题呢?我认为,问题在于引用..但我尝试了不同的变体,但没有任何帮助......
答案 0 :(得分:1)
使用&#39;`&#39;仅在列名称周围。当您在值中传递`asd`时,它认为它应该从名为&#39; asd&#39;的列中获取值。如果您想使用单引号传递变量值。