我已经在Ubuntu上安装灯,一切工作正常,我试图localhost/testphp()
工作正常,但是当我把它的代码显示值,如果我回应他们,但它并没有插入他们的数据库,它不给错误的MySQL连接。使用POST方法发送表单数据MySQL连接不工作Ubuntu?
<form action="form.php" method="POST">
<label>Email:</label>
<input type="text" name="name">
<label>Password</label>
<input type="password" name="pass">
</form>
这里 是PHP代码
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
echo "hello I am here !<br/>";
$con=mysqli_connect("localhost","root","123","login");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$name = $_POST['name'];
$password = $_POST['pass'];
echo " Name: ".$name." <br/>Password: ".$password;
mysqli_query($con,"INSERT INTO login_data (username, password) VALUES ('". $name ."', '". $password ."')");
//it doesnt insert the data
//how do i check the error of that query ?
mysqli_close($con);
?>
帮助!
尝试添加'的error_reporting(E_ALL);'在顶部,这样你会得到错误的page.Or'退出( “这里”)。 –
您在'$ sql'声明中有语法错误。添加'ini_set('display_errors',1); error_reporting(E_ALL);'到脚本的顶部找出原因。 –
我添加了'ini_set('display_errors',1);''和'error_reporting(E_ALL);'在脚本的顶部,仍然是相同的 – Waqas