INTO本地主机不起作用

INTO本地主机不起作用

运行SELECT * FROM用户后,该表没有任何区别。

    $firstName = $_POST["firstName"];
    $lastName = $_POST["lastName"];
    $dateOfBirth = $_POST["dateOfBirth"];
    $gender = $_POST["gender"];
    $fitnessLevel = $_POST["fitnessLevel"];
    $number = $_POST["number"];
    $address = $_POST["address"];
    $password = $_POST["password"];

    $user = 'root';
    $pass = 'root';
    $db = 'gymmembers';
    $db = new mysqli('localhost',$user,$pass,$db) or die("Error, try again");


    mysqli_query($db, "INSERT INTO users(`firstName`,`lastName`,`dateOfBirth`,`gender`,`fitnessLevel`,`number`,`address`,`password`)
                  VALUES('$firstName','$lastName','$dateOfBirth','$gender','$fitnessLevel','$number','$address','$password')" or die(mysqli_error()));


我可以回显任何变量并显示它们,因此表单中的数据将传递到此处。

谢谢 :-)

最佳答案

实际上,您将die(mysqli_error())放入了不正确的mysqli_query()内,请执行以下操作:-

 mysqli_query($db, "INSERT INTO users(`firstName`,`lastName`,`dateOfBirth`,`gender`,`fitnessLevel`,`number`,`address`,`password`)
            VALUES('$firstName','$lastName','$dateOfBirth','$gender','$fitnessLevel','$number','$address','$password')") or die(mysqli_error($db));


注意:-在$db中添加mysqli_error(),以便在发生任何错误时都可以知道。

关于php - PHP INSERT INTO本地主机不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36742484/

10-12 20:11