错误 您的 SQL 语法有错误;检查与-6ren">
gpt4 book ai didi

php - 错误插入

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

PHP 代码

<?php
$imageId = $_GET ["a"];
$likerId = $_GET ["b"];

// connection to the database
$dbhandle = mysql_connect ( "localhost", "root", "" ) or die ( "Unable to connect to MySQL" );

// select a database to work with
$selected = mysql_select_db ( "taxogram", $dbhandle ) or die ( "Could not select login" );

// execute the SQL query and return records
$result = mysql_query ( "INSERT INTO liker ( imageId , likerId ) VALUES ( '$imageId' , '$likerId' ) " );
echo mysql_error () . "<br>";
if ($result == 1) {
echo "sukses";
} else {
echo "gagal";
}
?>

错误

您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行的 'like ( imageId , likerId ) VALUES ( '1' , '2' )' 附近使用的正确语法嘎嘎

最佳答案

“喜欢”是reserved keyword .

$result = mysql_query ( "INSERT INTO `like` ( imageId , likerId ) VALUES ( '$imageId' , '$likerId' ) " );

另请注意 mysql_ functions are deprecated 。请改用 Mysqli 或 PDO。

关于php - 错误插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31250101/

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