SunQuest
           Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
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  
Old September 23rd, 2002, 08:15 PM
jonpress jonpress is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 jonpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jonpress
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.

Reply With Quote
  #2  
Old September 24th, 2002, 10:43 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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....

Reply With Quote
  #3  
Old September 24th, 2002, 02:44 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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!!

Reply With Quote
  #4  
Old September 24th, 2002, 02:54 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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.

Reply With Quote
  #5  
Old October 30th, 2002, 02:42 PM
jonpress jonpress is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 jonpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jonpress
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");

Reply With Quote
  #6  
Old November 15th, 2002, 07:04 AM
Lizardman Lizardman is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 113 Lizardman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > The case of the missing MySQL variable in PHP mail


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway