UDT & MySQL

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
User avatar
richbothe
Forum Members
Forum Members
Posts: 95
Joined: Tue Aug 15, 2006 5:34 pm
Location: Minnesota, USA

UDT & MySQL

Post 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
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: UDT & MySQL

Post by calguy1000 »

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.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm
Location: Comox Valley, BC

Re: UDT & MySQL

Post by Nullig »

Delete the "extract($row);" line and echo this:

Code: Select all

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

Return to “Developers Discussion”