Jump to content


Photo

mail() function problem


  • Please log in to reply
1 reply to this topic

#1 francoisp

francoisp
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationSouth Africa

Posted 14 April 2003 - 12:22 PM

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 ? :?

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 14 April 2003 - 01:00 PM

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]
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users