gpt4 book ai didi

php - PHP插入带引号的mysqli

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

我试图弄清楚为什么会出错:

$thisName = mysqli_real_escape_string($conn,"sonny's");

echo $sql = "INSERT INTO TEST_year (playername)
VALUES ('$thisName')";
mysqli_query($conn,$sql) or die(mysqli_error());


尝试执行此操作时出现此错误:

警告:mysqli_error()恰好需要1个参数,第25行的TEST_update_leaderboards.php中给出的参数为0

我试过只写“ sonnys”,一切都很好……我在这里想念什么?

任何帮助表示赞赏,并在此先感谢:-)

最佳答案

您的错误表明mysqli_error需要$ conn参数。
但您也可能希望更改为准备好的语句。

mysqli_error($conn)

关于php - PHP插入带引号的mysqli,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28008995/

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