插入新记录时出错 - Mysql

时间:2017-09-01 00:52:40

标签: php mysql

我是mysql的新手。任何人都可以告诉我这个代码有什么问题。它连接到数据库但不插入数据。

当我按sumbit时,这就出现了...... "您已成功连接错误插入新记录"

<?php


DEFINE ('DB_HOST', 'localhost'); // Host name
DEFINE ('DB_USER', '');
DEFINE ('DB_PSWD', '');
DEFINE ('DB_NAME', '');


$dbcon = mysqli_connect(DB_HOST, DB_USER, DB_PSWD, DB_NAME);

if (!$dbcon) {
    die('Error Connecting to Database');
    }
echo 'you have been connected successfully';


   $title = $_POST['title'];
   $first_name = $_POST['first_name'];
   // $surname = $_POST ['surname'];
   // $gender = $_POST ['gender'];
   // $dob = $_POST ['dob'];
   // $street_address = $_POST ['street_address'];
   // $suburb = $_POST ['suburb'];
   // $state = $_POST ['state'];
   // $home_phone = $_POST ['home_phone'];
   // $mobile_phone = $_POST ['mobile_phone'];
   // $work_phone = $_POST ['work_phone'];
   // $email = $_POST ['email'];
   // $martial_status = $_POST ['martial_status'];
   // $occupation = $_POST ['occupation'];
   // $parent_name = $_POST ['parent_name'];
   // $preferred_dr = $_POST ['preferred_dr'];
   // $medicare_no = $_POST ['medicare_no'];

   $sqlinsert = "INSERT INTO Patient Details Table (Title,First Name) VALUES ('$title', '$first_name')";

if (!mysqli_query($dbcon, $sqlinsert)) {
    die('Error Inserting New Record');
    }
else
{ 
    echo 'New Record Inserted';
}




?>

0 个答案:

没有答案