|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
The case of the missing MySQL variable in PHP mail
I am trying to use a variable from a PHP database along with completed form information. The result is that PHP mail does not output the variable.
Here is some sample code beginning with the MySQL query: $query = mysql_query("SELECT DatePosted, Email, Description FROM somedatabase WHERE ID LIKE '$ID'"); while ($row = mysql_fetch_array($query)){ echo ("<p><strong>Here is the ID : $ID</strong></p>"); echo ("<p><strong>Here is the Description: $Description</strong></p>"); echo ("<p><strong>Here is the Email: $Email</strong><p>" . $row["Email"] . "</p>" . "<p>" . $row["Description"] . "</p>"); $newdescription=$row["Description"]; <============================ I TRIED PASSING THIS NEW VARIABLE function show_form($email="", $formmessage="",$subject="") { ?> <body> <h2>Send an E-mail</h2> <form action="SOMEFILE.php3" method="POST"> <p><strong>Your E-mail address:</strong> <input type=text name=email size=30 value="<?echo $email?>"><br> <strong>Subject: </strong> <input type="text" name="subject" size="52" content="ddd" value="<?echo $subject?>"><br> <strong>Your Message:</strong><br> <textarea rows=10 cols=50 name=formmessage> <?echo $formmessage?> <============================ THIS ALSO GETS PASSED </textarea><br> <input type="submit" value=" Send E-mail"> </p> </form> <? } } $bubba = "From: $emailrn The sender is replying to your classified seen in family lifern Contact the sender at $emailrn Here is the classified that interests the sender:rn $newdescriptionrn <============================ THIS IS FROM THE SQL DATABASE BUT DOES NOT SHOW UP IN THE E-MAIL!!!! $formmessagern"; <============================ THIS IS FROM THE FORM & DOES PASS echo ("<p>3 HERE IS BUBBA $bubba</p>"); <============================ THIS OUTPUTS ON THE SCREEN CORRECTLY $message=$bubba; <============================ HERE IS THE IMPORTANT NEW VARIABLE TO BE PASSED IN THE FORM echo ("<p>3 HERE IS MESSAGE $bubba</p>"); <============================ THIS OUTPUTS ON THE SCREEN CORRECTLY if (!isset($email) or !isset($formmessage)) { show_form(); } else { if (empty($email) or empty($formmessage)) { echo "<H1>There is a Problem:</H1>"; if (empty($email)) { echo "Type in your e-mail address."; } if (empty($formmessage)) { echo "Enter a message."; } show_form($email,$subject,$formmessage); } else { if (empty($subject)) { $subject="Enter a subject"; } $sent = mail( "someone@someplace.com",$subject, $message,"From: $email"); <=========== THIS CALLS THE MESSAGE if ($sent) { echo "<H1>Your Message Has Been Sent.</H1>"; } else { echo "<H1>There is a Problem:</H1> <p>The server was unable to send your mail."; } } } ================================================== ====== The result is everything appears in the e-mail, but there is a blank where $newdescription should be. Any ideas???? Thanks. |
|
#2
|
|||
|
|||
|
RE: The case of the missing MySQL variable in PHP mail
I would check that something is actually getting assigned to $newdescription initially. Put an echo right after its assignment....
|
|
#3
|
|||
|
|||
|
RE: The case of the missing MySQL variable in PHP mail
Thanks for the feedback. I tried printing the $newdescription in every conceivable place and it output the correct information. I also tried different approaches to querying the database and had the same results.
The e-mail shows a gap where the variable should be. I'm lost!! |
|
#4
|
|||
|
|||
|
RE: The case of the missing MySQL variable in PHP mail
I don't see where the $newdescription is passed. You need to pass as an arguement into your show_form function. Then put the value of $newdescription into a form element with the name of newdescription for it to get POSTed and be available after the form is submitted.
|
|
#5
|
|||
|
|||
|
RE: The case of the missing MySQL variable in PHP mail
Thanks for all the great help. I took your advise and entered a hidden imput value in the form, like the following which passed on the variable:
<input type="hidden" name="ID" value="SomeVariable"); |
|
#6
|
|||
|
|||
|
RE: The case of the missing MySQL variable in PHP mail
Try this, maybe:
Immediately after this: function show_form($email="", $formmessage="",$subject="") { Add: global $newdescription; And if this doesn't seem to do it, also declare $newdescription as a global BEFORE you initially set it. This may help you out. |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > The case of the missing MySQL variable in PHP mail |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|