php燃料42000错误

时间:2012-12-14 04:50:21

标签: php fuelphp

我没有弄到什么问题。这是我得到的完整错误:

Fuel\Core\Database_Exception [ 42000 ]: SQLSTATE[42000]: Syntax error or access violation:
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL 
server version for the right syntax to use near 'to, from, message, checked) VALUES ('1', 
'freddy', 'bob', 'message', '1')' at line 1 with query: "INSERT INTO chatmes (id, to, from, 
message, checked) VALUES ('1', 'freddy', 'bob', 'message', '1')"

这是我的PHP代码,据说给了我错误:

<?php

define('DOCROOT', __DIR__.DIRECTORY_SEPARATOR);                 
define('APPPATH', realpath('/var/www/vhosts/grubber.co.nz/httpdocs/fuel/app/').DIRECTORY_SEPARATOR);
define('PKGPATH', realpath('/var/www/vhosts/grubber.co.nz/httpdocs/fuel/packages/').DIRECTORY_SEPARATOR);
define('COREPATH', realpath('/var/www/vhosts/grubber.co.nz/httpdocs/fuel/core/').DIRECTORY_SEPARATOR);                  
require APPPATH.'bootstrap.php';

error_reporting(-1);
ini_set('display_errors', 1);

$to = $_GET['to'];
$from = $_GET['from'];
$message = $_GET['message'];


$dquotes = '"';
$squotes = "'";

$message = str_replace($dquotes, "&quot", $message);
$message = str_replace($squotes, "&#039", $message);

DB::insert('chatmes')->set(array('id' => '1', 'to' => 'freddy', 'from' => 'bob', 'message' => 'message', 'checked' => '1'))->execute();

?>

我不知道我做错了什么。我正在使用的连接是 PDO

目前唯一给我错误的一行是数据库更新查询。

2 个答案:

答案 0 :(得分:1)

尝试在此结尾添加分号,

更改您的DB :: insert查询创建者

 INSERT INTO chatmes (id, to, from, 
     message, checked) VALUES ('1', 'freddy', 'bob', 'message', '1');"

答案 1 :(得分:0)

我已经弄清楚了,它与我的查询无关,它是燃料。它不喜欢数据库fromsendertoreceiver。 谢谢大家的帮助。