douwen1006 2013-09-20 21:56
浏览 54
已采纳

如何在不实现预处理语句的情况下使用mysqli?

<?php

...........

$connection = mysqli_connect('......com', 'login', 'password', 

'dbname'); 
if (!$connection) { 
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}

echo "Connection Successful";



// creating a query 
mysqli_query($connection, "INSERT INTO `users` (`userid`,`firstname`, `lastname`, `username`, `email`, 

`password`) VALUES (NULL, $firstname, $lastname, $username,$email,$password);");
mysqli_close($connection);



// printing to the screen
echo "Welcome $lastname . You have successfully logged in!";

?>

The connection is OK, but the values do not get inserted. How can I improve my code? I do not understand why the values donot get inserted into the database. I have checked the variables, they are fine.

  • 写回答

3条回答 默认 最新

  • duanmu2015 2013-09-20 22:00
    关注

    try this "INSERT INTO users (userid,firstname, lastname, username, email,

    password) VALUES (NULL, '$firstname', '$lastname', '$username','$email','$password');"

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?