Mysql Query is not Working in Php File
I am using original(no-change) ezsql-mysql class in php. everything works
great but one query in one page. As I copy the code base from some other
working pages everything needed like the classes and functions are already
added. Just before the problem query there is another query which is
working normally. Also the query with problem is working outside of php
file when I directly copy paste it to the phpmyadmin.
$db->query("
BEGIN;
INSERT INTO places (name, latitude, longitude)
VALUES ('Place of $event_name', '$latitude', '$longitude');
INSERT INTO events (place_code, event_name, start_time, owner_id)
VALUES (LAST_INSERT_ID(),'$event_name', '$start_time', '$owner_id');
COMMIT;
");
//this echo part was just for copying to phpmyadmin
echo "
BEGIN;
INSERT INTO places (name, latitude, longitude)
VALUES('Place of $event_name', '$latitude', '$longitude');
INSERT INTO events (place_code, event_name, start_time, owner_id)
VALUES(LAST_INSERT_ID(),'$event_name', '$start_time', '$owner_id');
COMMIT;
";
Everytime I use that page my server generates an error log in the
directory of that page. and the error is
[29-Sep-2013 07:29:35] PHP Warning: 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 'INSERT INTO places (name, latitude, longitude)
VALUES ('Place of asd', '39.76' at line 2 in
/home7/eyselnet/public_html/business/injoin/demo/sql/ez_sql_mysql.php on
line 233
In the worst case I can change my code to make it work in a different way.
But instead of that I am asking for help to understand. because it look so
strange that a query which work normally on phpmyadmin is having problem
in the php file.
thanks in advance.
No comments:
Post a Comment