无法将数据插入数据库

时间:2014-06-05 10:53:17

标签: php mysql

将详细信息上传到数据库但未插入任何内容  Unable to insert data to database ..

   $name  = $_POST['name'];
   $phon  = $_POST['phon'];
   $file  = $_POST['file'];
   $Email = $_POST['Email'];

   echo($name);
   echo($phon);        
   echo($file);

   echo($Email);

   if (isset($_POST['submit'])) {
       # code...

       $connect = mysql_connect("localhost","root","") or die("couldnot connect");
   }

   mysql_select_db("vikash");

   mysql_query("INSERT into student (name,email,phon,photo) values ('$name','$Email','$phon','$file') ");

2 个答案:

答案 0 :(得分:0)

如果您的表单已成功提交,那么该表单将存储在您的数据库中。如果不工作,请告诉我你的最新情况。

//检查此

$name = $_POST['name'];
$phon = $_POST['phon'];
$file = $_POST['file'];
$Email = $_POST['Email'];
if (isset($_POST['submit'])) {
   $connect = mysqli_connect("localhost","root","") or die("could not connect");
   mysqli_select_db("vikash");
   mysqli_query("INSERT into student (name,email,phon,photo) 
     values('$name','$Email','$phon','$file') ");
 }

答案 1 :(得分:0)

尝试在php页面上回显SQL /查询,然后尝试在MySQL工作台上运行输出。 并尝试从那里找出它,更容易确定问题。

谢谢, Sambhav