简体   繁体   English

MySQL更新未更新

[英]MySQL update isn't updating

<?php
require("header.inc.php");
?>

<?php
if (isLoggedIn()) {
    if (isset($_POST['CKey_Button'])) {
        if (!isset($_POST['CKey'])) {
            die("Error: The Character Key field was not set.");
        }
    }

    $CKey = $_POST['CKey_Button'];

    mysql_select_db("samp");

    $query = mysql_query("SELECT `id` FROM `players` WHERE `CharacterKey` = '" . mysql_real_escape_string($_POST['CKey']) . "' LIMIT 1");

    if (mysql_num_rows($query)) {
        mysql_select_db("ucp");
        mysql_query("UPDATE `users` SET `CharacterID` = '" . $CKey . "' WHERE `name` = '" . $user['name'] . "'");
        header("./Dashboard.php");
        exit;
    }
    else {
        header("./index.php");
        exit;
    }
}
else {
    header("./index.php");
    exit;   
}
?>

That is the code but it isn't updating and it just a blank screen, does anyone know why this could be happening(I have just started coding php so be nice if it's a newbie error). 那是代码,但它没有更新,只是一个空白屏幕,有人知道为什么会这样吗(我刚刚开始编码php,所以如果是新手错误,那就好了)。

EDIT: I have fixed it I was using $CKey as the button and not the actual key, hope this makes sense, I also changed = '" . $CKey . "' to = " . $CKey 编辑:我已修复它我使用$ CKey作为按钮,而不是实际的键,希望这是有道理的,我也将='“。$ CKey。”'改为=“。$ CKey

使用mysql_error()查看查询中是否有错误

mysql_query($query) or die ('Error updating database: '.mysql_error());

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

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