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.

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?