Reputation: 1085
I don't get what's wrong. 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 supposedly 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, """, $message);
$message = str_replace($squotes, "'", $message);
DB::insert('chatmes')->set(array('id' => '1', 'to' => 'freddy', 'from' => 'bob', 'message' => 'message', 'checked' => '1'))->execute();
?>
I don't know what I am doing wrong. Also the connection I'm using is PDO.
At the moment the only line thats giving me a error is the DB update query.
Upvotes: 0
Views: 657
Reputation: 1085
I have figured it out, it had nothing to do with my query, it was fuelphp. It didn't like the database from
to sender
and to
to receiver
.
Thanks guys for helping.
Upvotes: 0
Reputation: 11
try putting a semicolon at the end like this,
changer your DB::insert query creator
INSERT INTO chatmes (id, to, from,
message, checked) VALUES ('1', 'freddy', 'bob', 'message', '1');"
Upvotes: 1