dongtiao2105 2014-11-10 08:34
浏览 18

Php简单插入不起作用

I am trying to insert some values in to mysql database via php code. It is straight forward, but it is not working. Here is my code:

$first = $_POST['first'];
$last = $_POST['last'];
$address = $_POST['address'];
$mjesto = $_POST['mjesto'];
$ptt = $_POST['ptt'];
$email = $_POST['email'];
$phone = $_POST['phone'];

$a=1;

$conn = new mysqli('server', 'user', 'pass', 'db');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} 



$sql = "insert into imtecEvents values
   ('".$a."', '".$first."', '".$last."', '".$address."', '".$mjesto."', '".$ptt."', '".$email."', '".$phone."', '".$a."' )";

$conn->query($sql);
  • 写回答

3条回答 默认 最新

  • duannai5858 2014-11-10 08:48
    关注

    Try using this:

    INSERT INTO table_name (column1,column2,column3,...)
    VALUES (value1,value2,value3,...);
    
    评论

报告相同问题?