mysqli没有将数据发布到数据库中

时间:2013-07-29 20:44:53

标签: php mysql database mysqli phpmyadmin

以下mysqli查询未执行,因为我检查了我的'users'表并且它不包含任何记录:

//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变量下面执行,我有一些其他代码在执行时在/ users /目录中创建一个文件夹,每当我检查我的在线目录时,它确实被创建了,但是再次,问题是查询不会在数据库上发布任何内容。

有什么建议吗?

谢谢你们!

1 个答案:

答案 0 :(得分:0)

在查询后添加以下行:

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

并查看它是否打印任何内容。根据错误信息采取相应行动,即至少将其添加到您的问题中。