gpt4 book ai didi

php - 字段列表中的未知列。 PHP + MySQL

转载 作者:可可西里 更新时间:2023-11-01 06:53:10 25 4
gpt4 key购买 nike

我正在尝试向 phpmyadmin 中的表添加值,但出现错误:“字段列表”中的未知列“...”。

这是我的代码:

    <?php   

//preparing the patch to copy the uploaded file
$target_path = "images/";

//adding the name of the file, finishing the path
$target_path = $target_path . basename( $_FILES['image']['name']);

//moving the file to the folder
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['image']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}

//getting input from the form
$name = $_POST['game'];
$description = $_POST['beschrijving'];

//preparing the query to insert the values
$query = "INSERT INTO tblGames (name, description, image) VALUES ($name, $description,". $target_path .")";

//opening connection to db
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect: ' . mysql_error());
}

//selecting a db
mysql_select_db("BouncingGiani", $link) or die(mysql_error());

//running the query
$result = mysql_query($query) or die (mysql_error());

//closing the connection
mysql_close($link);

?>

因此,当我在上一页的表单中输入 fds 作为名称时,我得到:“字段列表”中的未知列“fds”。我以前从未发生过这种情况,我不知道发生了什么。

最佳答案

我认为

$query = "INSERT INTO tblGames (name, description, image) VALUES ($name, $description,". $target_path .")";

应该是

$query = "INSERT INTO tblGames (name, description, image) VALUES ('$name', '$description', '". $target_path ."')";

关于php - 字段列表中的未知列。 PHP + MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18368017/

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