簡體   English   中英

查詢未在表中插入字符串數據

[英]Query not inserting string data into table

我正在嘗試使用PHP將一些數據插入MySQL數據庫。 我擁有的代碼可以在localhost上正常運行,但是當我在服務器上嘗試使用reg_user_id,reg_user_access_level和reg_user_status時,不會插入所有其他字段。

請幫忙,我已經浪費了一天時間試圖解決這個問題。

到這里一切都很好

PHP是:

else {
    //sort the data
    $reg_user_name = mysql_real_escape_string($_POST['reg_user_name']);
    //create a salt for the password before encryption, use the same when retrieving the password!
    $salt = 'mysalt';//not actually this
    //first encryption
    $reg_user_password = sha1($_POST['reg_user_password']);
    //second encryption with salt
    $reg_user_password = sha1($salt.$reg_user_password);
    $reg_user_password = mysql_real_escape_string($reg_user_password);
    /*** strip injection chars from email ***/
    $reg_user_email = preg_replace( '((?:\n|\r|\t|%0A|%0D|%08|%09)+)i','',$_POST['reg_user_email']);
    $reg_user_email = mysql_real_escape_string($reg_user_email);

    //connect to the db
    include '../-useful_scripts/php/mysqli_connect_dsnydesign.php';

    //check the connection
    if($dbc) {

        /*** check for existing username and email ***/
        $query = "SELECT reg_user_name, reg_user_email FROM reg_users WHERE reg_user_name = '{$reg_user_name}' OR reg_user_email = '{$reg_user_email}';";
        $result = mysqli_query($dbc, $query);
        $row = mysqli_fetch_row($result);
        if (sizeof($row) > 0) {
            foreach($row as $value) {
                echo $value.'<br>';
            }
            if($row[0] == $reg_user_name) {
                $errors[] = 'Sorry, the username is already in use';
            }
            elseif($row[1] == $reg_user_email) {
                $errors[] = 'This Email address is already subscribed';
            }
            mysqli_free_result($result);
        }
        else {
            /*** create a verification code ***/
            $verification_code = uniqid();
            //set the query
            $query = "INSERT INTO reg_users(reg_user_id, reg_user_name, reg_user_password, reg_user_email, reg_user_access_level, reg_user_status) VALUES (NULL, '$reg_user_name', '$reg_user_password', '$reg_user_email', '1', '$verification_code');";
            //run the query
            if(mysqli_query($dbc, $query)) {

之后就繼續通知提交。

檢查服務器和本地主機上使用的PHP版本號是否相同。 最新版本的PHP中不推薦使用mysql_real_escape_string。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM