francoisp Posted April 14, 2003 Share Posted April 14, 2003 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 ? :? Quote Link to comment https://forums.phpfreaks.com/topic/346-mail-function-problem/ Share on other sites More sharing options...
effigy Posted April 14, 2003 Share Posted April 14, 2003 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] Quote Link to comment https://forums.phpfreaks.com/topic/346-mail-function-problem/#findComment-1110 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.