-2

以下 mysqli 查询不执行,因为我检查了我的“用户”表并且它不包含任何记录:

//connection.php//

$db_connect = mysqli_connect('myremotehost', 'myremoteuser', 'mypass', 'mydatabase');

if(mysqli_connect_errno($db_connect)){
echo mysqli_connect_error();
exit();
}

//

include 'database/connection.php';
$username = $_POST['username'];
$password = md5($_POST['password']);
$email = $_POST['email'];
$email_code = md5($_POST['username'] + microtime());
$gender = $_POST['gender'];
$ip = getenv('REMOTE_ADDR');

$sql = "INSERT INTO `users` (username, password, email, email_code, gender, ip, signup, lastlogin, notescheck) VALUES('$username','$password','$email','$email_code','$gender','$ip',NOW(),NOW(),NOW())";
$query = mysqli_query($db_connect, $sql);



 //below are the forms with their respective 'input names' that are equal to: username, email and gender (values 'm' & 'f').

 //The action of the actual form is action="" this file.

我知道这段代码是直接在 $sql 和 $query 变量下面执行的问题是查询没有在数据库上发布任何内容。

有什么建议么?

多谢你们!

4

1 回答 1

0

在查询后添加这一行:

if (!$query) { die(mysqli_error($db_connect)); }

看看它是否打印任何东西。根据错误消息采取相应措施,即至少将其添加到您的问题中。

于 2013-07-29T20:47:17.070 回答