简体   繁体   English

MySqli返回NULL值,无法插入或选择

[英]MySqli is returning NULL for values and cannot insert or select

My problem is that my db have no errors and still ignore my inserts, selects etc. So i tried var_dump() and it gives NULL for all variables. 我的问题是我的数据库没有错误,仍然忽略了我的插入,选择等。所以我尝试了var_dump(),它为所有变量提供了NULL。 That is my connection query: 那就是我的连接查询:

 $this->conexao = new mysqli('localhost:3307','root','', 'construsite');

And this is wrong, i think: 我认为这是错误的:

 public 'conexao' => 
 object(mysqli)[2]
  public 'affected_rows' => null
  public 'client_info' => null
  public 'client_version' => null
  public 'connect_errno' => null
  public 'connect_error' => null
  public 'errno' => null
  public 'error' => null
  public 'error_list' => null
  public 'field_count' => null
  public 'host_info' => null
  public 'info' => null
  public 'insert_id' => null
  public 'server_info' => null
  public 'server_version' => null
  public 'stat' => null
  public 'sqlstate' => null
  public 'protocol_version' => null
  public 'thread_id' => null
  public 'warning_count' => null

and my function to insert that is ignored: 和我插入的函数将被忽略:

public function registro(){
    //comando sql para inserir novo cliente
    $comando = "INSERT INTO clientes(id, nome_cliente, email_cliente, telefone_cliente, senha_cliente, data_nasc_cliente) "
    . "VALUES (NULL, '$this->nome_cliente', '$this->email_cliente', '$this->telefone_cliente', '$this->senha_cliente', STR_TO_DATE( '$this->data_nasc_cliente', '%Y/%d/%m')";
    //executa o comando
    $registro_resultado = $this->conexao->query($comando); //executa o comando
    return $registro_resultado;
}

I tried to find in google and here but i could not. 我试图在谷歌和这里找到,但我找不到。 (Sorry my bad english!!) (对不起,我的英语不好!!)

Id is primary key, and primary key doesn't accept null. Id是主键,主键不接受null。 if your primary key auto increment so remove id from insert query. 如果您的主键自动递增,请从插入查询中删除ID。

$comando = "INSERT INTO clientes(nome_cliente, email_cliente, telefone_cliente, senha_cliente, data_nasc_cliente) "
    . "VALUES ('$this->nome_cliente', '$this->email_cliente', '$this->telefone_cliente', '$this->senha_cliente', STR_TO_DATE( '$this->data_nasc_cliente', '%Y/%d/%m'))";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM