我试图将数据插入到我的表中。但它显示了其他部分。我无法插入数据。请帮忙。我的价值观名称是' name',' mail'和' pass'。如在第二个查询中。
<?php
if(array_key_exists('name', $_POST) AND array_key_exists('mail', $_POST)
AND array_key_exists('pass', $_POST)) {
if($_POST['name'] == "") echo "<p>Name is required</p>";
if($_POST['mail'] == "") echo "<p>Mail is required</p>";
if($_POST['pass'] == "") echo "<p>Password is required</p>";
if($_POST['name'] != "" AND $_POST['mail'] != "" AND $_POST['pass']
!= ""){
$link=mysqli_connect("localhost", "root", "", "mydata");
if(mysqli_connect_error()) echo "Couldn't connect to server,
Please try again later.";
else {
$query = "SELECT `id` FROM TABLE1 WHERE `mail` =
'".mysqli_real_escape_string($link, $_POST['mail'])."'";
if($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_row($result);
if($row != "") echo "Email already taken";
else {
$query = "INSERT INTO `table1`
('name','mail','password') VALUE ('".mysqli_real_escape_string($link,
$_POST['name'])."','".mysqli_real_escape_string($link,
$_POST['mail'])."','".mysqli_real_escape_string($link, $_POST['pass'])."')";
if(mysqli_query($link, $query)) echo "yes";
else echo "nooo";
}
}
}
}
};
?>
答案 0 :(得分:0)
为什么不在代码中添加mysqli_error()..以查看无法插入的原因。