大家好,谢谢,如果你能告诉我我需要帮助的错误,请各位帮助我
<?php
$servername = "localhost"; $username = "root"; $password = "";
$dbname = "kurd";
mysql_connect("localhost","root","","kurd") or die ("not connect data base");
mysql_select_db("kurd") or die ("no found table");
if(isset($_POST['submit'])){
$name = $_POST['name'];$lastname = $_POST['lastname'];
$password =_POST['password'];
$query =" INSERT INTO kurdstan (name,lastname,password) VALUES ('$name','$lastname','$password')";
if(mysql_query($query)){
echo "<h3>THANKS FOR INSERT DATA GOOD LUCK</h3>";
}
}
?>
答案 0 :(得分:0)
在您的代码中添加else
到
if(mysql_query($query)){
echo "<h3>THANKS FOR INSERT DATA GOOD LUCK</h3>";
}
导致,
if(mysql_query($query)){
echo "<h3>THANKS FOR INSERT DATA GOOD LUCK</h3>";
}
else {
echo 'MYSQL Error: ' . mysql_error();
}
您可能会看到错误而非您的消息,这可能有助于您追踪问题。
注意强>
mysql
扩展程序现已弃用,您应使用mysqli
http://php.net/manual/en/book.mysqli.php或PDO http://php.net/manual/en/book.pdo.php。您还应该阅读SQL注入 - 您的数据在用于查询字符串之前需要转义。