doukong6031 2016-03-20 11:47
浏览 68
已采纳

SQL插入二进制设置为30

I am trying to use a binary field to show if the user has confirmed there email address . For some reason it always seems to be set at 30 , Is this normal and can you tell me why thanks.

PHP CODE

<?php 
include 'php/base.php';



$status;
//setup some variables/arrays
$action = array();
$action['result'] = null;

$firstName = $_GET['firstname'];
$lastName = $_GET['lastname'];
$email = $_GET['email'];
$password = $_GET['password'];
$password = md5($password);

$add = mysqli_query($link,"INSERT INTO `users` VALUES(NULL,'$firstName','$lastName','$password','$email',1)");



         
if($add){
    //the user was added to the database    
             
    //get the new user id
    $userid = mysqli_insert_id($link);
                 
    //create a random key
    $key = $firstName . $email . date('mY');
    $key = md5($key);
                 
    //add confirm row
    $confirm = mysqli_query($link,"INSERT INTO `confirm` VALUES(NULL,'$userid','$key','$email')"); 
                 
    if($confirm){

      include 'php/functions.php';
                 
      //let's send the email
      //include the swift class
      include_once 'lib/swift_required.php';
                   
      //put info into an array to send to the function
      $info = array(
          'fname' => $firstName,
          'email' => $email,
          'key' => $key
      );


                   
      //send the email
      if(send_email($info)){
            
        $status = "true" ;


      }else{   

        $status = "false";
      }
    }

      
  }

  echo "true";


  ?>

PHP MY ADMIN

enter image description here

enter image description here

</div>
  • 写回答

1条回答 默认 最新

  • duancao2082 2016-03-20 12:15
    关注

    You probably want to use BIT data type or Boolean instead.

    Binary datatypes are not suited for storage of the boolean values.

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

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?