php - SQL 插入二进制设置为 30

标签 php mysql sql

我正在尝试使用二进制字段来显示用户是否已确认那里的电子邮件地址。出于某种原因,它似乎总是设置为 30,这正常吗,你能告诉我为什么吗,谢谢。

PHP 代码

<?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 我的管理员

enter image description here

enter image description here

最佳答案

您可能想使用 BIT数据类型或 bool 值。

二进制数据类型不适合存储 bool 值。

关于php - SQL 插入二进制设置为 30,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36113288/

相关文章:

PHP正则表达式匹配句子

php - 关系表 PDO 查看全部

php - 根据内容中的日期获取最近 N 周的 MySQL 行

mysql - 每个有条件的 parent 的平均值

php - 在 BD 中搜索存储有 á 元素的值

mysql - MySQL 有多少实时未提交事务

mysql - 我正在尝试使用具有可变 FK 的架构创建一个表(订单)

php - 在php中处理多种类型的数组

sql - SQL Server 中的临时表

mysql - 在不为数据库更改重新编码的情况下复制 MySQL 中的行