Jump to content


This topic is now archived and is closed to further replies.


mail() function problem

Recommended Posts

Hi there


When i run the following code


include \'db.php\';

$username = $_POST[\'username\'];

$email = mysql_query("SELECT email_address from users where username=\'$username\'");

$subject = "My Subject";

$message = "My Message";

mail($email, $subject, $message, "From: OurDomaim<webmaster@domain.com>nX-Mailer: PHP/" . phpversion());

echo \'The E-Mail has been send !!\';



I get the error Warning: mail() expects parameter 1 to be string, resource given in E:Program FilesApache GroupApache2htdocs..123.php on line 9


What am I doing wrong ? :?

Share this post

Link to post
Share on other sites

queries return resource id\'s which identify 2d arrays of the table results. you need to fetch rows, then print columns of that row. try this:



$email = mysql_query(\"SELECT email_address from users where username=\'$username\'\");


$address = mysql_fetch_row($email);


mail($address[0], $subject ...


Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.