php mysqli查询无法正常工作

时间:2016-03-31 17:27:08

标签: php mysql mysqli

我试图将表中的值增加一个,但我并不是真的知道mysql而且我不知道什么是错的。它似乎没有问题但是当我检查数据库时,数字没有改变。提前致谢! :)

    $con = mysqli_connect($db_host, $db_user, $db_pass, $db_name);

if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
    echo "it works!";
}

switch ($_POST['found']) {
    case "facebook":
        mysqli_query($con,"UPDATE `found` SET `number` = 'number + 1' WHERE `id` = 'Facebook'");


        break;

1 个答案:

答案 0 :(得分:1)

试试这个:

 case "facebook":
    mysqli_query($con,"UPDATE `found` SET number = number + 1 WHERE `id` = 'Facebook'") or die(mysqli_error($con));

希望这有帮助。