SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2004
    Location
    ZA
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question PHP Mailing result of SQL Query

    Morning Ladies and Gents. I've run into a prob and need some guidance.
    I've created an HTML form that POST's info to a php file . From this
    php file i populate various MySQL DB's but it's the last step that i need help with.

    Through the POST several variables are assigned and i need these variables mailed to several addresses determined by the SQL Query. Script Follows.

    $location = "XXX";
    $username = "XXX";
    $password = "XXX";
    $database= "XXX";
    $conn = mysql_connect("$location","$username","$password");
    if (!$conn) die ("Could not connect MySQL Server");
    mysql_select_db($database,$conn) or die ("Could not open database XXX");
    mysql_query("select mail from $GROUP where mail like "%"");



    What i need to do next is to query a table determined by $GROUP, the actual query is "select mail from $GROUP where mail like "%" . This will retrieve all the e-mail addresses in that table . I then need to e-mail all the addresses from that result , i guess the mail ( "ronald@XXX.co.za", "NetAlert","Blah"); comes in here . Any ideas


    Regards

    ./ronald

  2. #2
    SitePoint Zealot
    Join Date
    Mar 2004
    Location
    Milano
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried what you proposed?
    Anyway you have 3 problems in your query
    PHP Code:
    mysql_query("select mail from $GROUP where mail like "%""); 
    - you are not returning a pointer to the result;
    - MySQL uses single quotes and note double quotes
    - "mail like '%'" is absolutely not necessary since every row in your table will be found this way (except for null values but in this case is better using IS NOT NULL). You can delete the whole where section.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •