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

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.