Solved

php/sql query syntax

Posted on 2008-10-07
5
826 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 109

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 109

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…

791 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