473,378 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

email address from mysql

ddtpmyra
333 100+
Need help as a newbie I'm trying to create auto email everytime the users execute the button below. Please tell me what wrong with my mail.php file

[PHP]
<html>
<head>


<form action="mail.php" method="POST" enctype="multipart/form-data">

<input type="submit" value="mail now">
</p>
</form>

</body>
</html>
[/PHP]

Here's the PHP email (mail.php) and I don't know how to do it, but I know that my sql is just working fine.

[PHP]
<?php

# Connect to the database
$dbLink = mysql_connect("localhost", "xxx", "xxxxxxxx")
or die("Error! Failed to connect to the MySQL server!");
mysql_select_db("cmr", $dbLink)
or die("Error! Failed to select a database!");

#query
$query="
SELECT m.email, f.approval1
from filestorage f, members m
where f.approved='N'
and f.approval1=m.name


$result = @MYSQL_QUERY($query);

while ($row = mysql_fetch_array ($result)) {
// HTML body
$body = "Hello <font size=\"4\">" . $row["full_name"] . "</font>, <p>";
$body .= "<i>Your</i> personal photograph to this message.<p>";
$body .= "Sincerely, <br>";
$body .= "PHPMailer List manager";

// Plain text body (for mail clients that cannot read HTML)
$text_body = "Hello " . $row["approval1"] . ", \n\n";
$text_body .= "Your personal photograph to this message.\n\n";
$text_body .= "Sincerely, \n";
$text_body .= "PHPMailer List manager";

$mail->Body = $body;
$mail->AltBody = $text_body;
$mail->AddAddress($row["email"], $row["approval1"]);

if(!$mail->Send())
echo "There has been a mail error sending to " . $row["email"] . "<br>";

// Clear all addresses and attachments for next loop
$mail->ClearAddresses();
$mail->ClearAttachments();
}


?>
[/PHP]
Sep 15 '08 #1
3 1623
pbmods
5,821 Expert 4TB
Heya, ddtpmyra.

Where do you initialize $mail?
Sep 15 '08 #2
ddtpmyra
333 100+
I'm totally clueless, can you show me a simple email script that email address comes from mysql or any database?

thanks!
Sep 15 '08 #3
pbmods
5,821 Expert 4TB
You should be pretty close. You'll just need to add something like this:

Expand|Select|Wrap|Line Numbers
  1. $result = @MYSQL_QUERY($query);
  2.  
  3. require_once 'class.phpmailer.php';
  4. $mail = new PHPMailer();
  5.  
  6. while ($row = mysql_fetch_array ($result)) {
  7.  
The require_once() path might change depending on where you keep the PHPMailer class file.
Sep 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Dariusz | last post by:
I am a newbie to PHP, and newer still to MySQL. I have nearly finished writing (offline for use online) a PHP script that deals with people adding and deleting themselves off a mailing list...
2
by: Jim | last post by:
I have contact info including email address in MySQL. If I use php to extract them into online directory, can a spambot harvest the address? or does the spambot read the raw php code? I...
5
by: cfoley1970 | last post by:
I have an online directory of alumni from a high school that runs PHP with a MySql backend containing contact info, email addresses, etc. Some of the alumni have begun to complain about receiving...
4
by: vishal | last post by:
how can i verify the email address entered by client??? is there any readily available function for that in php or mysql????? else suggest me some links for verifying email address enetered...
2
by: Nigi | last post by:
I've made a mysql database with php front end which, in part, contains mailing lists. I've used a mailto: link to create a new email with their names in the bcc: field. Unfortunatley their is a...
4
by: Ken D. | last post by:
I have an asp page that collects data on referrals. The user inputs the information and selects the rep to receive the referral. My data is being saved to a backend database (SQL) and the user is...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
9
by: axlq | last post by:
I'm trying to figure out a MySQL query expression to match an email address. Here's the situation: User registers on my site with a "plus style" email address (username+key@example.com). This...
1
by: eddiethebutler | last post by:
I have used some software (Forms To Go) to make a PHP script that writes to a mySQL database (I am collecting names and emails for newsletters). I have customised it so that it only writes to the...
4
by: canajien | last post by:
I need to have a php script pull data from a mysql table and send it in the body of an email I know I can get the script to display information in the browser by doing this: $i=0; while ($i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.