This topic is locked

syntax error on event

8/11/2007 1:50:43 PM
PHPRunner General questions
Allenh author

PHP runner v4.0

PHP version 4.4.7
I've set up a test db for creating audit records.

table : id, item, desc

table_log : id, item, desc
On the table - on edit page, I've tried every event,

onload - Save old data record in another table

before record update - insert a record into another table
and I always get a similar error message...it's telling me it's a syntax error, but I can't figure out how to fix it. Using php 4.4.7

----

Technical information

Error type 256

Error description 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 'desc) SELECT item, desc FROM table where `table`.`id`=8' at line 1

URL www.air-crane.ca/testbed2/table_edit.php?editid1=8

Error file /home/airhypen/public_html/testbed2/include/dbconnection.php

Error line 26

SQL query select `id`, `item`, `desc` From `table` where `table`.`id`=8

Solution
This is a general error. It occurs when thereis an error in event code or in SQL.
Send your SQL or event code along with full error message tosupport@xlinesoft.com.

----

Here's the event code...

global $where;

// Parameters:

// $where - string with WHERE clause pointing to record to be edited

//** Save old data record in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO table_log (item, desc) SELECT item, desc FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);
Any help would be greatly appreciate

Sergey Kornilov admin 8/12/2007

desc is a reserved keyword in MySQL. You have to rename this field or use backticks around it `desc`.

Allenh author 8/12/2007

I've changed it desc to item2, and I'm stilling getting an the same error.

Here's the code...
function EditOnLoad()

{global $where;

// Parameters:

// $where - string with WHERE clause pointing to record to be edited

//** Save old data record in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO table_log (item, item2) SELECT (item,item2) FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);
and the error

Error type 256

Error description 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 'table where `table`.`id`=10' at line 1

URL www.air-crane.ca/testbed2/table_edit.php?editid1=10

Error file /home/airhypen/public_html/testbed2/include/dbconnection.php

Error line 26

SQL query select `id`, `item`, `item2` From `table` where `table`.`id`=10

Solution
This is a general error. It occurs when thereis an error in event code or in SQL.
Send your SQL or event code along with full error message tosupport@xlinesoft.com.

Allenh author 8/13/2007

discovered you can't use 'table' as a table name. Got it working thanks for your patience and help.
A.