huafang
V2EX  ›  PHP

帮我看下哪里错了

  •  
  •   huafang · Oct 5, 2013 · 3886 views
    This topic created in 4799 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
    Paranoid
    Oct 5, 2013
    1
    sql ="INSERT INTO `a1`.`user`(username, password) VALUES('$user', '$pass')"; +上=引号试试.
    CalifLove
    CalifLove
    Oct 6, 2013
    2
    $sql = "INSERT INTO user (username,password) VALUES (".$user.",".$pass.")";
    faceair
    faceair
    Oct 6, 2013❤️1
    3
    加上单引号能避免数据为空时出错
    huafang
    huafang
    OP
    Oct 6, 2013
    4
    @Paranoid 试验成功 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   930 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 21:30 · PVG 05:30 · LAX 13:30 · JFK 16:30
    ♥ Do have faith in what you're doing.