Solved

php/sql query syntax

Posted on 2008-10-07
5
832 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

690 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