Page 1 of 1

UDT & MySQL

Posted: Mon Jan 21, 2008 6:01 pm
by richbothe
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

Re: UDT & MySQL

Posted: Mon Jan 21, 2008 6:24 pm
by calguy1000
why not just skip the 'extract' call and use $row['email'], $row['subject'], etc.

Re: UDT & MySQL

Posted: Mon Jan 21, 2008 6:31 pm
by Nullig
Delete the "extract($row);" line and echo this:

Code: Select all

 echo "$row['email'], $subject, $message, $headers";
Nullig