dongqi7631 2013-08-10 15:21
浏览 41
已采纳

查询不将字符串数据插入表中

I am trying to insert some data into a MySQL database using PHP. The code I have works fine on localhost, but when I try it on my server the reg_user_id, reg_user_access_level and reg_user_status are inserted while all the other fields are not.

Please help, I've already wasted a day trying to sort this out.

everything up to here is fine

The PHP is:

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( '((?:
||\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)) {

just goes on to notify of submission after this.

  • 写回答

1条回答 默认 最新

  • dplbf4340 2013-08-10 15:39
    关注

    Check that you are using the same PHP version number on your server and your localhost. mysql_real_escape_string has been deprecated in the latest version of PHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路