gpt4 book ai didi

php - 使用 URL 将值(例如 URL)插入 MySQL 数据库时出错

转载 作者:行者123 更新时间:2023-11-29 07:23:11 25 4
gpt4 key购买 nike

我正在我的网站上工作,但我现在无法访问 myPhpAdmin,所以我尝试制作一个脚本来为搜索内容插入值。但是,当我访问链接 website.com/search/create.php?l=link&d=description&t=title 时,出现错误。这个

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'link, description, title)' at line 1

这是我的脚本的样子。

$link = "https://website.com";
$description = "The homepage of the site";
$title = "Home";

// sql to create table
$sql = "INSERT INTO search (link, description, title) VALUES (".$link.", ".$description.", ".$title.")";

if (mysqli_query($conn, $sql)) {
echo "it's working";
} else {
echo "it's not working?" . mysqli_error($conn);
}

最佳答案

替换

$sql = "INSERT INTO search (link, description, title) VALUES ('".$link."', '".$description."', '".$title."')";

代替:

$sql = "INSERT INTO search (link, description, title) VALUES (".$link.", ".$description.", ".$title.")";

你试图插入一个没有'的字符串

关于php - 使用 URL 将值(例如 URL)插入 MySQL 数据库时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55187407/

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