简体   繁体   English

我无法更新我的SQL行

[英]I can't update my SQL row

I try to update data in my row, but I can't, hmm I get message, that everything went good, but row doesn't change at all. 我尝试更新行中的数据,但是我无法收到消息,说一切进展顺利,但行完全没有变化。 I think I do something wrong with incrementing, I mean that data in row is a string, that's why ++ may not work on it. 我认为我在递增时做错了什么,我的意思是行中的数据是一个字符串,这就是为什么++不能在它上工作的原因。 I use echo to see what data is in for example $ip, $lower etc, to see on what data script is going to work, and everything goes good, but UPDATE doesn't. 我使用echo查看例如$ ip,$ lower等中的数据,查看哪些数据脚本将起作用,并且一切正常,但是UPDATE无效。 This is my code: 这是我的代码:

$ip = $_SERVER['REMOTE_ADDR'];
echo $ip_for_map;
$ip_data_for_map = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=".$ip));
$country_upper = $ip_data_for_map->geoplugin_countryCode;
echo $country_upper;
$country_lower = strtolower($country_upper);
echo $country_lower;
$main_for_table = 1;
$take_from_sql_country = "SELECT $country_lower FROM table WHERE main='$main_for_table'";
$country_taken_from_table = mysqli_query($dbc, $take_from_sql_country);
$row_sl_map = mysqli_fetch_assoc($country_taken_from_table);
$row_country_data = $row_sl_map['$country_lower']; 
$row_final = $row_country_data++;
$update_countrys_row = "UPDATE table SET $country_lower='$row_final' WHERE main='$main_for_table'";
$update_country_final = mysqli_query($dbc, $update_countrys_row);
if(!$update_country_final)
{
    echo 'BADSHIT';
}
else
{
    echo 'BRAVO';
}
$row_country_data = $row_sl_map['$country_lower'];

This line is literally looking for an array key called $country_lower , not the key contained in the variable $country_lower . 该行实际上是在寻找一个名为$country_lower的数组键,而不是变量$country_lower包含的键。

Remove the single quotes. 删除单引号。

It should also be noted that, even if the query results in no update (as is the case in your erroneous code), the query itself still succeeds. 还应注意,即使查询没有更新(在错误代码中就是这种情况),查询本身仍然会成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM