Re: Help! How do i mail a value from a mysql databse?
| From: | David Robley | Date: | Wed, 14 Nov 2001 01:44:39 +0000 |
| Subject: | Re: Help! How do i mail a value from a mysql databse? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-74520@lists.php.net to get a copy of this message | ||
On Wed, 14 Nov 2001 04:26, Raymond wrote:
> Hi!
>
> I'm trying to send a mail with password to the new user of my website,
> but ......... Does anyone know how to put the variable inside my mail?
>
> I have tried this:
>
> ---------------------->
> else {
>
> // sende kundeopplysninger til databasen
>
> $db = mysql_connect("localhost", "root");
>
> mysql_select_db("subway",$db);
>
> $sql = "INSERT INTO nettkunder
> (fornavn,etternavn,firma,adresse,postnr,sted,telefon,epost) VALUES
>
> ('$fornavn','$etternavn','$firma','$adresse','$postnr','$sted','$telefo
>n','$ epost')";
>
> $result = mysql_query($sql);
>
> echo "Velkommen som kunde hos Subway.\n";
>
> }
>
> $db = mysql_connect("localhost", "root");
>
> mysql_select_db("subway",$db);
>
>
> $id = mysql_query("GET id FROM nettkunder WHERE epost = '$epost'",$db);
>
> mail("$epost", "Velkommen som kunde hos Subway", "Her har du ditt
> passord: $myrow["id"] \n God appetitt! Hilsen Subway");
The value you are passing in $myrow["id"] doesn't exist in your code. You
need to do
$myrow = mysql_fetch_row($id);
after your mysql_query to populate the row data. And your query should
probably read "SELECT id FROM...
--
David Robley Techno-JoaT, Web Maintainer, Mail List Admin, etc
CENTRE FOR INJURY STUDIES Flinders University, SOUTH AUSTRALIA
Washed the cat - took HOURS to get the hair off my tongue!