Jump to content

mail() function problem


francoisp

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<[email protected]>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 ? :?

Link to comment
https://forums.phpfreaks.com/topic/346-mail-function-problem/
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:

 

[php:1:1e16e70089]<?php

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

 

$address = mysql_fetch_row($email);

 

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

?>[/php:1:1e16e70089]

Link to comment
https://forums.phpfreaks.com/topic/346-mail-function-problem/#findComment-1110
Share on other sites

Archived

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

×
×
  • Create New...

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.