gpt4 book ai didi

php - 使用PHP插入MySQL数据库的某些字段

转载 作者:太空宇宙 更新时间:2023-11-03 10:22:53 25 4
gpt4 key购买 nike

我无法正确编译它。

$username = mysql_real_escape_string($_GET['username']);
$about = mysql_reaL_escape_string($_GET['about']);
$icebreaker = mysql_reaL_escape_string($_GET['icebreaker']);


$query = "UPDATE '$mysql_database'.main SET about = '$about', icebreaker = '$icebreaker' WHERE username = '$username';";

我得到了错误

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 ''a4396957_users'.main
SET about = 'testing', icebreaker = 'ice' WHERE us' at line 1

这个声明中是否遗漏了什么?

最佳答案

不要用撇号或引号引用数据库名称

$query = "UPDATE `$mysql_database`.`main` SET `about` = '$about', `icebreaker` = '$icebreaker' WHERE `username` = '$username';";

用`代替'

关于php - 使用PHP插入MySQL数据库的某些字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9521206/

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