PHP和MySQL - 查询数据库时出错

时间:2016-07-13 08:07:55

标签: php mysql

我正在使用这本书" O' Reilly Head First PHP&的MySQL"学习PHP。 今天我写了这段代码:

<?php

$dbc = mysqli_connect('localhost','xxx','xxx','aliendatabase')
  or die('Error conecting to the database');

$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, how many, alien_description, what_they_did, fang_spotted, other, email) VALUES ('Sally', 'Jones', '3 days ago', '1 day', 'four', 'green', 'we just talked', 'yes', 'I have seen him', ' sally@gregs-list.net')";

$result = mysqli_query($dbc, $query) 
    or die ('Error querying database');

mysqli_close($dbc);

?>

与数据库的连接工作正常,我已经测试过了。但是当我运行代码时,我收到了这个错误:

Error querying database

可能是什么问题?

0 个答案:

没有答案