huafang
V2EX  ›  PHP

帮我看下哪里错了

  •  
  •   huafang · Oct 5, 2013 · 3696 views
    This topic created in 4669 days ago, the information mentioned may be changed or developed.
    $sql ="INSERT INTO `a1`.`user`(username, password) VALUES($user, $pass)";
    mysql_query($sql,$conn);
    4 replies    1970-01-01 08:00:00 +08:00
    Paranoid
        1
    Paranoid  
       Oct 5, 2013
    sql ="INSERT INTO `a1`.`user`(username, password) VALUES('$user', '$pass')"; +上=引号试试.
    CalifLove
        2
    CalifLove  
       Oct 6, 2013
    $sql = "INSERT INTO user (username,password) VALUES (".$user.",".$pass.")";
    faceair
        3
    faceair  
       Oct 6, 2013   ❤️ 1
    加上单引号能避免数据为空时出错
    huafang
        4
    huafang  
    OP
       Oct 6, 2013
    @Paranoid 试验成功 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1132 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    ♥ Do have faith in what you're doing.