multiple insert query
I have the following query that I'm using to populate a multiple insert form. It generates a list of meeting dates:
SET @num = -1;
SELECT DATE_ADD('2015-01-01 19:30', interval @num := @num+1 week) AS start_date,
DATE_ADD( ADDTIME('2015-01-01 19:30', '01:30' ), interval @num week) AS end_date,
num.* FROM num
WHERE num.i IS NOT NULL
the table 'num' has one field, i, and row values 1-12
When I run the query using Navicat or WebYog, it runs properly and returns a set of dates.
However, if I try to use it within Dreamweaver, I get the following 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 'SELECT DATE_ADD('2015-01-19 20:00', interval @num := @num + 1 week) AS start_dat' at line 1
The date value and weekly interval have been passed to the page.
I've googled and the error seems to suggest that I need to have apostrophe's in place - but I can't see where!
The code on the page looks like this, if anyone can help:
$p1_rsMeets = "2015-01-01";
if (isset($_POST['StartDate'])) {
$p1_rsMeets = $_POST['StartDate'];
}
$p2_rsMeets = "1";
if (isset($_POST['rep1'])) {
$p2_rsMeets = $_POST['rep1'];
}
$p3_rsMeets = "01:30";
if (isset($_POST['MeetDuration'])) {
$p3_rsMeets = $_POST['MeetDuration'];
}
$p4_rsMeets = "-1";
if (isset($_POST['numbermeets'])) {
$p4_rsMeets = $_POST['numbermeets'];
}
mysql_select_db($database_connRIBIT, $connRIBIT);
$query_rsMeets = sprintf("SET @num = -1; SELECT DATE_ADD(%s, interval @num := @num + %s week) AS start_date, DATE_ADD(ADDTIME(%s,%s ), interval @num week) AS end_date, num.* FROM num WHERE num.i IS NOT NULL LIMIT %s", GetSQLValueString($p1_rsMeets, "date"),GetSQLValueString($p2_rsMeets, "int"),GetSQLValueString($p1_rsMeets, "date"),GetSQLValueString($p3_rsMeets, "date"),GetSQLValueString($p4_rsMeets, "int"));
$rsMeets = mysql_query($query_rsMeets, $connRIBIT) or die(mysql_error());
$row_rsMeets = mysql_fetch_assoc($rsMeets);
$totalRows_rsMeets = mysql_num_rows($rsMeets);
Much obliged
Cheers
Chris