close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

multiple insert query

Thread began 1/23/2015 9:01 am by Sweens | Last modified 1/27/2015 11:47 am by Sweens | 1353 views | 6 replies |

Sweens

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

Sign in to reply to this post

Jason ByrnesWebAssist

from the manual:

mysql_query() sends a unique query (multiple queries are not supported) to the currently active database on the server that's associated with the specified link_identifier.

http://php.net/mysql-query


in your query you are trying to execute 2 statements:
1 - SET @num = -1;
2 - 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


multiple statements are not supported by mysql_query.

Sign in to reply to this post

Sweens

Thanks Jason.

I've tried to get round this by changing it to:

SELECT DATE_ADD('2015-01-01 19:30', interval -1 := -1+1 week) AS start_date,
DATE_ADD( ADDTIME('2015-01-01 19:30', '01:30' ), interval -1 week) AS end_date,
num.* FROM num
WHERE num.i IS NOT NULL

Perhaps unsurprisingly (as I don't know what I'm doing!) this hasn't worked. I don't really understand why it works in navicat as a quert, but doesn't work in Dreamweaver.

Cheers
Chris

Sign in to reply to this post

Jason ByrnesWebAssist

If you need help with this custom coding, we can help through a premiere support appointment:
http://www.webassist.com/premier_request.php

Sign in to reply to this post

Sweens

Hi Jason

I booked this over the weekend, for yesterday or today - but nobody has got back to me.

Cheers
Chris

Sign in to reply to this post

Jason ByrnesWebAssist

Ray sent a skype message yesterday to set up the appointment.

Sign in to reply to this post

Sweens

pm

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...