Solved

php/sql query syntax

Posted on 2008-10-07
5
828 Views
Last Modified: 2013-12-12
Hello, i am running joomla 1.0.15,  using fabrik 1.0.6, a form building component for Joomla, it gives the option of having the form perfom a php command - eq an sql query upon submission.

I was wondering if you could give me the proper structure for such a command

this is a sample sql query which I have run successfully from phpmyadmin

INSERT IGNORE INTO `jos_users` ( `name`,`username`)
(SELECT namel_newsletter,email_newsletter FROM `jos_fabrik_formdata_1` )

I know I need to add something like

$database->query($sql)

but I`m not sure of the exact syntax.

Any help would be greatly appreciated
0
Comment
Question by:dsrpmedia
  • 2
5 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 22690774
Try something like this...
// MAKE THE SQL STATEMENT
$sql = "INSERT IGNORE INTO `jos_users` ( `name`,`username`)
(SELECT namel_newsletter,email_newsletter FROM `jos_fabrik_formdata_1` )";
 
// DO THE QUERY
$database->query($sql)

Open in new window

0
 

Author Comment

by:dsrpmedia
ID: 22691205
thanks for the suggestion, but it didn `t quite work. I got an error message

'Parse error: syntax error, unexpected $end in /home/content/.../html/components/com_fabrik/fabrik.class.php(1575) : eval()'d code on line 6
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 22691496
That's a totally different issue.  Unexpected $end means that you have a conditional statement such as if() or foreach() with an open brace { that is not terminated by a matching closing brace }

Usually you can use an IDE or text editor to find unbalanced braces or parentheses.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question