I have a query, which when run from within phpMyAdmin, it works, however when integrated within a website written in Perl, it fails and throws errors. Both are run with a connection to the same database, and from coding/formatting side when integrated into the Website, all is correct and the same as other queries.
Any help with this would be much appreciated - Thanks!
MySQL Query:
CREATE TEMPORARY TABLE tmp_lecture_days (
timeslot_id int(50)
);
INSERT INTO tmp_lecture_days (timeslot_id)
SELECT DISTINCT tab_appointment.timeslot_id
FROM tab_appointment WHERE lecture_id = '1115';
SELECT COUNT(timeslot_id)
FROM tmp_lecture_days;
MySQL Query in Perl:
$query
= &statement_database(
"CREATE TEMPORARY TABLE tmp_lecture_days (
timeslot_id int(50)
);
INSERT INTO tmp_lecture_days (timeslot_id)
SELECT DISTINCT tab_appointment.timeslot_id
FROM tab_appointment WHERE lecture_id = '1115';
SELECT COUNT(timeslot_id)
FROM tmp_lecture_days;");
my ($days) = $query->fetchrow_array;
Error Log:
7.3.2011 10:14:12 error 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 '; 7.3.2011 10:14:12 error INSERT INTO tmp_lecture_days (timeslot_id) 7.3.2011 10:14:12 error SELECT DISTINCT tab_appoi' at line 3