doutui2016 2018-06-27 13:25
浏览 65
已采纳

PHP / SQL:从具有良好查询的数据库接收的“false”值

I have a php script who ask my database with PDO to verify if some values sent exists. If they exists, the database respond with the id of this line's value. I tested the query on mysql and it works but the value received is false. This code is only for personal use. There is the code :

<?php
include("../template/pdo.php");
$query = $pdo->prepare("SELECT id_utilisateur FROM utilisateur
      WHERE `mail` IN ( ':mail' )
        AND `mdp` IN ( ':mdp' )");
$query->bindParam(':mail', $_GET['identifiant'], PDO::PARAM_STR);
$query->bindParam(':mdp', $_GET['mdp'], PDO::PARAM_STR);
$success = $query->execute();

if($success)
{
  $result = $query->fetch();
  var_dump($result); //bool(false) actually
  if($result == false){
    $message = "Try again.";
  }
  else{
    $message = "Congratulation !";
  }
}

I tested everything I know :

  • $_GET is a print/paste from my database table to my url and i have print him

  • Printed/pasted on phpMyAdmin the query from PDOStatement::debugDumpParams() with my $_GET values

  • pdo.php work and used on other scripts

  • No log in my logs files.

Someone can help me ? Thanks !

  • 写回答

1条回答 默认 最新

  • dongmi1995 2018-06-27 21:11
    关注
    • If you are testing against a single value use =, not IN.
    • If you have a list of values, several changes are needed.
    • The bind code will add quotes, you already have quotes. Remove your quotes.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 采用的你的方案
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备