我正在尝试在数据库中插入值,但无法执行此操作
<?php
if(isset($_POST['submit']))
{
$fullname=$_POST['fullname'];
$contactnumber=$_POST['contactnumber'];
$email=$_POST['email'];
$qualification=$_POST['qualification'];
$postappliedfor=$_POST['postappliedfor'];
$sql_connection=mysql_connect("localhost","root","admin","interview");
mysql_select_db("interview,$sql_connection") or die("cannot select DB");
$sql=mysql_query("INSERT INTO `USERDEATILS`(`id`,`fullname`,`contactnumber`,`email`,`qualification`,`postappliedfor`) VALUES('','$fullname','$contactnumber','$email','$qualification','$postappliedfor')");
if($sql){
echo "done";
}
else{
echo "There is an error!!";
}
}
?>发布于 2015-01-31 16:42:21
更改mysql_select_db("interview,$sql_connection")行
至
Mysql_select_db(“面试”,$sql_connection)
发布于 2015-01-31 17:12:16
除了Manuel Ramirez所说的,你可能想要检查以确保你的mysql数据类型'id‘没有设置为NOT NULL。您可能还希望将to auto_increment属性添加到'id‘字段,以便在插入记录时省略该属性
发布于 2015-01-31 19:00:49
使用正确的mysql语法:
$sql_connection = mysql_connect('localhost', 'mysql_user', 'mysql_password');从mysql_connect中删除database_name。
在mysql_connect中,我们只能传递5参数
但是我建议你使用MySQLi,就像这样:
$connection = mysqli_connect('localhost', 'username', 'password', 'database');https://stackoverflow.com/questions/28249742
复制相似问题