Solved

php/sql query syntax

Posted on 2008-10-07
5
819 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 108

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 108

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now