[英]Inserted data not going to phpMyAdmin database
I'm having a problem with my data not going through to phpMyAdmin. 我的数据无法通过phpMyAdmin遇到问题。 The server and database connects the PHP but the data is not inserted into the table. 服务器和数据库连接PHP,但数据未插入表中。
This is what I have so far. 到目前为止,这就是我所拥有的。
<?php
$dbConnect = mysqli_connect("xxxxxxx", "xxxxx","xxxxx");
if (!$dbConnect)
die("<p>The database server is not available.</p>");
echo "<p>Successfully connected to the database server.</p>";
$dbSelect = mysqli_select_db( $dbConnect,"sxxxxxxx_db" );
if (!$dbSelect)
die("<p>The database is not available.</p>");
echo "<p>Successfully opened the database.</p>";
$sql = "INSERT INTO customer (Name,Password,Email,Phone) VALUES ('$_POST[namefield]', '$_POST[pwdfield]','$_POST[email]','$_POST[phone]' ) ";
mysqli_query($sql,$dbConnect);
mysqli_close($dbConnect);
if(isset($_POST['namefield']) && isset($_POST['pwdfield']) && isset($_POST['cpwdfield']) && isset($_POST['email']) && isset($_POST['phone']) && isset($_POST['submit']))
{
$name = $_POST['namefield'];
$password = $_POST['pwdfield'];
$cpassword = $_POST['cpwdfield'];
$email = $_POST['email'];
$phone = $_POST['phone'];
if ($_POST["pwdfield"] == $_POST["cpassword"])
mysqli_query("INSERT INTO user VALUES('','$password')") or die(mysqli_error());
else {
echo("Password did not match! Try again. ");
//Connect $unsafe_variable = $_POST["user-input"]; $safe_variable = mysql_real_escape_string($unsafe_variable); mysql_query("INSERT INTO table (column) VALUES ('" . $safe_variable . "')"); //Disconnect
您已关闭数据库连接
mysqli_close($dbConnect);
稍微改变sql
$sql = "INSERT INTO customer (Name,Password,Email,Phone) VALUES ('".$_POST['namefield']."', '".$_POST['pwdfield']."','".$_POST['email']."','".$_POST['phone']."' ) "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.