V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
xiaoyanbot
V2EX  ›  PHP

使用 PDO prepare 之后提交返回 00000,但没插入数据,返回信息为 null,很奇怪

  •  
  •   xiaoyanbot · Nov 27, 2017 · 2392 views
    This topic created in 3079 days ago, the information mentioned may be changed or developed.

    代码:

    $sql = "INSERT INTO wenshidu(temp,shidu,time) VALUES (?,?,$time)";
    $stmt = $db->prepare($sql);
    $stmt->bindValue(1, '21');
    $stmt->bindValue(2, '22');
    $result = $stmt->execute();
    
    echo "<br>插入结果:";
    var_dump($result);
    echo "<br>返回日志:<br>";
    var_dump($db->errorInfo());
    
    ~~~
    
    返回信息:
    
    ~~~
    
    插入结果:bool(false) 
    错误日志:
    array(3) { [0]=> string(5) "00000" [1]=> NULL [2]=> NULL }
    
    ~~~
    
    1 replies    2017-11-27 23:44:57 +08:00
    xiaoyanbot
        1
    xiaoyanbot  
    OP
       Nov 27, 2017
    找到原因了, 数据库名称 错误, 没提示
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   786 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 21:23 · PVG 05:23 · LAX 14:23 · JFK 17:23
    ♥ Do have faith in what you're doing.