What´s wrong in this SQL?
Posted: Sun Jan 24, 2010 11:36 am
Hi
Working on hierachies in MySQL.
This is my SQL for adding a child.
Running this SQL in my DB-client (Sequel-Pro) works perfect.
The exact same code in PHP on the same DB (local) gives the MySQLerror:
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 'SELECT @myLeft := lft FROM meny WHERE namn = 'ParentMenu'; UPDATE meny S' at line 3
Is it a charset issue, linebreak type? Trying to change the both but...
Working on hierachies in MySQL.
This is my SQL for adding a child.
Code: Select all
"LOCK TABLE meny WRITE;
SELECT @myLeft := lft FROM meny
WHERE namn = 'ParentMenu';
UPDATE meny SET rgt = rgt + 2 WHERE rgt > @myLeft;
UPDATE meny SET lft = lft + 2 WHERE lft > @myLeft;
INSERT INTO meny(namn, lft, rgt) VALUES('ChildMenu', @myLeft + 1, @myLeft + 2);
UNLOCK TABLES;"Running this SQL in my DB-client (Sequel-Pro) works perfect.
The exact same code in PHP on the same DB (local) gives the MySQLerror:
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 'SELECT @myLeft := lft FROM meny WHERE namn = 'ParentMenu'; UPDATE meny S' at line 3
Is it a charset issue, linebreak type? Trying to change the both but...