Perhaps this is a syntax issue, but I'm having trouble extracting data from a field stored in a MySQL database where I have the php code in a UDT and I'm wondering if someone could take a look at this.
I created a form that, when submitted, it should send an email to all the email addresses stored in the db. Everything seems to work, except for "extract($row)" and my experience with this isn't quite good enough to figure this one out on my own.
Here's code I have for processing the form:
************ code for query, results, loop, extract, and output**************
//query for mass email form
$sql = "SELECT 'email' FROM `members` WHERE 'email' IS NOT null";
$results = mysql_query($sql)
or die(mysql_error());
//Line 40
//This loop checks all rows for an email address and stores them in the variable $email.
$rowcount = 0;
while ($row = mysql_fetch_array($results)) {
$rowcount++;
extract($row);
echo "$email, $subject, $message, $headers";
//$mailsent = mail($email, $subject, $message, $headers);
}
***************************
As you can see I set echo to determine what the output of $email is and here's what it comes back as:
*********** form results output follows ****************
email, test, test, From: communications@aomam.org
************************
The results output actually outputs the correct number of entries in the db, but as you can see it's outputting "$email" as 'email', thus not sending the email because it's not extracting the actual email addresses.
Any input on this would be very greatly appreciated.
Rich Bothe
UDT & MySQL
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: UDT & MySQL
why not just skip the 'extract' call and use $row['email'], $row['subject'], etc.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: UDT & MySQL
Delete the "extract($row);" line and echo this:
Nullig
Code: Select all
echo "$row['email'], $subject, $message, $headers";