0

尝试执行此查询:

$result = "INSERT INTO `user`(`username`, `ip`, `country`) VALUES ('$username','$location[ip]','$location[country]')";

@mysql_query($result) or die("Error:". mysql_error());

尝试过单引号和双引号的组合,但不断出错:

Error:Unknown column 'ip' in 'field list'

列“ip”确实存在于数据库中,当我回显查询并在 PHPMyAdmin 中运行它时,它可以完美运行

INSERT INTO `user`(`username`, `ip`, `country`) VALUES ('name32','127.0.0.1','mycountry')
4

2 回答 2

1

我想你可能在数据库中打错了?我每隔一段时间就使用一次 IP,我从来没有遇到任何问题。是否可以将列命名为 IP(大写)?这可能会破坏事情

为确保名称正确,您可以将名称更改为“某物”并更改查询。如果它开始工作,它在名称区域中,否则你肯定知道它不是那个

于 2013-07-05T11:42:53.423 回答
1

像这样更改您的 SQL 查询

$result = "INSERT INTO `user` (`username`, `ip`, `country`) VALUES ('".$username."','".$location['ip']."','".$location['country']."')";
于 2013-07-05T11:43:27.340 回答