php fuel 42000 error

Posted by ryanc1256 on Stack Overflow See other posts from Stack Overflow or by ryanc1256
Published on 2012-12-14T04:50:20Z Indexed on 2012/12/14 5:03 UTC
Read the original article Hit count: 305

Filed under:
|

I don't get whats wrong. So this is the full error I get...

    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')"

and this my php code which is supposably giving me the error

<?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();

?>

I dont know what I am doing wrong?? Also the connection im using is PDO

At the moment the only line thats giving me a error is, the db update query

© Stack Overflow or respective owner

Related posts about php

Related posts about fuelphp