huafang
V2EX  ›  PHP

帮我看下哪里错了

  •  
  •   huafang · Oct 5, 2013 · 3817 views
    This topic created in 4757 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   ·   Privacy   ·   Solana   ·   4885 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 05:38 · PVG 13:38 · LAX 22:38 · JFK 01:38
    ♥ Do have faith in what you're doing.