searls03 Posted April 4, 2011 Share Posted April 4, 2011 ok, so I have this code and I need to know how to modify it so that the strings display properly............so that it wont display $string but instead whatever value it is.........can you please help: $to = "$email"; // Change this to your site admin email $from = "events@site.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <style type="text/css"> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id="apDiv1"> <table width="408" border="1" cellspacing="2" cellpadding="2"> <tr> <th width="90" scope="col">Event(s):</th> <th width="298" scope="col"> $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET["eventid"]." LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row["event"]; $startdate = $row["startdate"]; $enddate = $row["enddate"]; $description = $row["description"]; $location = $row["location"]; $subevent1 = $row["subevent1"]; $subevent2 = $row["subevent2"]; $subevent3 = $row["subevent3"]; $subevent4 = $row["subevent4"]; $subevent5 = $row["subevent5"]; $subevent6 = $row["subevent6"]; $subevent7 = $row["subevent7"]; $subevent8 = $row["subevent8"]; //this will echo the contents of each db row as they are iterated in the loop ############################# if (!empty($title1)) { echo "<br/>$title1:"; } if (!empty($title2)) { echo "<br/>$title2:" ; } if (!empty($title3)) { echo "<br/>$title3:"; } if (!empty($title4)) { echo "<br/>$title4:"; } if (!empty($title5)) { echo "<br/>$title5:"; } if (!empty($title6)) { echo "<br/>$title6:"; } if (!empty($title7)) { echo "<br/>$title7:"; } if (!empty($title8)) { echo "<br/>$title8:"; } } //etc etc </th> </tr> <tr> <th>Price:</th> <th> $total = $price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8 ; echo $total; </th> </tr> <tr> <th>Registrant:</th> <th><?php echo $name; ?></th> </tr> </table> </div> <div id="apDiv2"><?php echo $name; ?> <p> </p> <p> </p> <p><a href="index.php" target="_new"><strong>Troop 78 Home</strong></a></p> <p> </p> <p> </p> <p><strong><"></a></strong></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <img name="boyscout" src="button/boyscout.jpg" width="1180" height="700" border="0" id="boyscout" alt="" /> </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; $to = "@gmail.com"; // Change this to your site admin email $from = "events@site.net"; $subject = "New Registration for $event"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body> Hello, Aaron $name has registered for $event. they will owe $total = $price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8 ; echo $total; </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/ Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 Use double quotes, otherwise, unless you concatenate, the variables will not interpolate. Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196833 Share on other sites More sharing options...
searls03 Posted April 4, 2011 Author Share Posted April 4, 2011 so single quotes inside and double enclosing? Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196834 Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 so single quotes inside and double enclosing? Yes. Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196835 Share on other sites More sharing options...
searls03 Posted April 4, 2011 Author Share Posted April 4, 2011 thanks...... Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196836 Share on other sites More sharing options...
searls03 Posted April 4, 2011 Author Share Posted April 4, 2011 unexpected t-string: $sql = mysql_query("SELECT * FROM Registration WHERE eventid=".$_GET['eventid']." LIMIT 1"); Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196874 Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 If your column type is other than an integer then you need single quotes around the value. Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196880 Share on other sites More sharing options...
searls03 Posted April 4, 2011 Author Share Posted April 4, 2011 so now for this code : $event = $row['event']; $startdate = $row['startdate']; $enddate = $row['enddate']; $description = $row['description']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; I am getting Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a6254834/public_html/eventreg.php Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196884 Share on other sites More sharing options...
Maq Posted April 4, 2011 Share Posted April 4, 2011 Does it give you a line number? Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196886 Share on other sites More sharing options...
searls03 Posted April 4, 2011 Author Share Posted April 4, 2011 yeah.......but it is on all of those.......when I delete first one, it moves to next line.....etc....etc....etc..... line78 Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196887 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 I think this error usually means you're missing a quote, or mixing them up. Can you post a few lines above and echo out $sql to see what the actual value is? Another thing I mentioned before, is if eventid is not and integer you will need to change it to (added single quotes): WHERE eventid='".$_GET["eventid"]."' LIMIT 1"); Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197206 Share on other sites More sharing options...
searls03 Posted April 5, 2011 Author Share Posted April 5, 2011 <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'> $sql = mysql_query("SELECT * FROM Registration WHERE eventid='".$_GET["eventid"]."' LIMIT 1"); while($row = mysql_fetch_array($sql)){ $event = $row['event']; $startdate = $row['startdate']; $enddate = $row['enddate']; $description = $row['description']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; (not sure what you meant by echo out $sql?) Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197435 Share on other sites More sharing options...
Maq Posted April 5, 2011 Share Posted April 5, 2011 Sorry, I meant do something like this: $sql = "SELECT * FROM Registration WHERE eventid='".$_GET["eventid"]."' LIMIT 1"; echo $sql; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197459 Share on other sites More sharing options...
searls03 Posted April 5, 2011 Author Share Posted April 5, 2011 $sql = "SELECT * FROM Registration WHERE eventid='".$_GET["eventid"]."' LIMIT 1"; echo $sql; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $event = $row['event']; $startdate = $row['startdate']; $enddate = $row['enddate']; $description = $row['description']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; still same errors..... Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197461 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2011 Share Posted April 6, 2011 You seem to be posting code sections, not continuous code, since the code you posted has a mixture of HTML and PHP with the starting "<?php" tag. Please post all of the code. Ken Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197539 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Query member data from the database and ready it // Process the form if it is submitted // Set error message as blank upon arrival to page $errorMsg = ""; // First we check to see if the form has been submitted if (isset($_POST['eventid'])){ $name = ereg_replace("[^A-Z a-z0-9]", "", $_POST['name']); // filter everything but numbers and letters $event = ereg_replace("[^A-Z a-z0-9]", "", $_POST['event']); // filter everything but spaces, numbers, and letters $eventid = ereg_replace("[^A-Z a-z0-9]", "", $_POST['eventid']); // filter everything but spaces, numbers, and letters $subevent1 = ereg_replace("[^A-Z a-z0-9]", "", $_POST['subevent1']); // filter everything but spaces, numbers, and letters $subevent2 = ereg_replace("[^A-Za-z0-9]", "", $_POST['subevent2']); // filter everything but lowercase letters $subevent3 = ereg_replace("[^A-Za-z0-9]", "", $_POST['subevent3']); // filter everything but lowercase letters $subevent4 = ereg_replace("[^A-Za-z0-9]", "", $_POST['subevent4']); // filter everything but lowercase letters $subevent5 = ereg_replace("[^A-Za-z0-9]", "", $_POST['subevent5']); // filter everything but lowercase letters $subevent6 = ereg_replace("[^A-Z a-z0-9]", "", $_POST['subevent6']); // filter everything but $subevent7 = ereg_replace("[^A-Z a-z0-9]", "", $_POST['subevent7']); // filter everything but $subevent8 = ereg_replace("[^A-Z a-z0-9]", "", $_POST['subevent8']); // filter everything but $userid = ereg_replace("[^A-Z a-z0-9]", "", $_POST['userid']); // filter everything but $email = ereg_replace("[^A-Z a-z0-9.@]", "", $_POST['email']); // filter everything but $sql = "Insert INTO Events (name, event, eventid, userid, subevent1, subevent2, subevent3, subevent4, subevent5, subevent6, subevent7, subevent8, email) VALUES('$name','$event','$eventid','$userid','$subevent1','$subevent2','$subevent3','$subevent4','$subevent5','$subevent6','$subevent7','$subevent8', '$email')"; $rs = mysql_query($sql) or die ("Problem with the query: $sql<br>" . mysql_error()); $total ="$price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8"; $to = "$email"; // Change this to your site admin email $from = "events@final.net46.net"; $subject = "Complete your registration"; //Begin HTML Email Message where you need to change the activation URL inside $message = "<html> <style type='text/css'> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'> $sql = "SELECT * FROM Registration WHERE eventid='".$_GET["eventid"]."' LIMIT 1"; echo $sql; $result = mysql_query($sql) or die(mysql_error()); while($row = mysql_fetch_array($result)){ $event = $row['event']; $startdate = $row['startdate']; $enddate = $row['enddate']; $description = $row['description']; $location = $row['location']; $subevent1 = $row['subevent1']; $subevent2 = $row['subevent2']; $subevent3 = $row['subevent3']; $subevent4 = $row['subevent4']; $subevent5 = $row['subevent5']; $subevent6 = $row['subevent6']; $subevent7 = $row['subevent7']; $subevent8 = $row['subevent8']; //this will echo the contents of each db row as they are iterated in the loop ############################# if (!empty($title1)) { echo '<br/>$title1:'; } if (!empty($title2)) { echo '<br/>$title2:' ; } if (!empty($title3)) { echo '<br/>$title3:'; } if (!empty($title4)) { echo '<br/>$title4:'; } if (!empty($title5)) { echo '<br/>$title5:'; } if (!empty($title6)) { echo '<br/>$title6:'; } if (!empty($title7)) { echo '<br/>$title7:'; } if (!empty($title8)) { echo '<br/>$title8:'; } } //etc etc </th> </tr> <tr> <th>Price:</th> <th> echo '$total'; </th> </tr> <tr> <th>Registrant:</th> <th><?php echo $name; ?></th> </tr> </table> </div> <div id='apDiv2'><?php echo $name; ?> <p> </p> <p> </p> <p><a href='index.php' target='_new'><strong>Troop 78 Home</strong></a></p> <p> </p> <p> </p> <p><strong><a href='http://www.cornhuskercouncil.org'>Cornhusker Council</a></strong></p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <img name='boyscout' src='button/boyscout.jpg' width='1180' height='700' border='0' id='boyscout' alt='' /> </body> </html>"; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; $to = "searls03@gmail.com"; // Change this to your site admin email $from = "events@final.net46.net"; $subject = "New Registration for $event"; //Begin HTML Email Message where you need to change the activation URL inside $message = '<html> <body> Hello, Aaron $name has registered for $event. they will owe $total = $price1 + $price2 + $price3 = $price4 + $price5 + $price6 + $price7 + $price8 ; echo $total; </body> </html>'; // end of message $headers = "From: $from\r\n"; $headers .= "Content-type: text/html\r\n"; $to = "$to"; // Finally send the activation email to the member mail($to, $subject, $message, $headers); // Then print a message to the browser for the joiner print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; print "<br /><br /><br /><h4>OK $firstname, one last step to verify your email identity:</h4><br /> We just sent an Activation link to: $email<br /><br /> <strong><font color=\"#990000\">Please check your email inbox in a moment</font></strong> to click on the Activation <br /> Link inside the message. After email activation you can log in."; echo mysql_error(); // close if post exit(); // Exit so the form and page does not display, just this success message }// Close else after database duplicate field value checks // Close else after missing vars check //Close if $_POST ?> Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197546 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2011 Share Posted April 6, 2011 You're missing the terminating quote and semi-colon at the end of this string: <?php $message = "<html> <style type='text/css'> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'> ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197556 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 but there isn't supposed to be one there though Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197876 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2011 Share Posted April 6, 2011 Yes there is. You have to terminate the string with a "; or else you get the error you're getting. <?php $message = "<html> <style type='text/css'> #apDiv1 { position:absolute; left:338px; top:278px; width:311px; height:129px; z-index:1; } #apDiv2 { position:absolute; left:50px; top:207px; width:181px; height:149px; z-index:2; } #apDiv2 { text-align: center; } </style> </head> <body><div id='apDiv1'> <table width='408' border='1' cellspacing='2' cellpadding='2'> <tr> <th width='90' scope='col'>Event(s):</th> <th width='298' scope='col'>"; // <----- see the added "; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197887 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 if I do that, the php ends and the $message ends wont it? Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197889 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 as I suspected.........the code ended..........in the email, it stops where you added those at..... Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197898 Share on other sites More sharing options...
Maq Posted April 6, 2011 Share Posted April 6, 2011 You need to keep concatenating the message. $message .= "the rest of your HTML"; Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197905 Share on other sites More sharing options...
kenrbnsn Posted April 6, 2011 Share Posted April 6, 2011 You have to concatenate anything else onto the $message variable if you want more to appear in the email message. Where you have: <?php if (!empty($title1)) { echo '<br/>$title1:'; } if (!empty($title2)) { echo '<br/>$title2:' ; } if (!empty($title3)) { echo '<br/>$title3:'; } if (!empty($title4)) { echo '<br/>$title4:'; } if (!empty($title5)) { echo '<br/>$title5:'; } if (!empty($title6)) { echo '<br/>$title6:'; } if (!empty($title7)) { echo '<br/>$title7:'; } if (!empty($title8)) { echo '<br/>$title8:'; } ?> If you want those strings in the message you have to do something like <?php if (!empty($title1)) { $message .= '<br/>$title1:'; } if (!empty($title2)) { $message .= '<br/>$title2:' ; } if (!empty($title3)) { $message .= '<br/>$title3:'; } if (!empty($title4)) { $message .= '<br/>$title4:'; } if (!empty($title5)) { $message .= '<br/>$title5:'; } if (!empty($title6)) { $message .= '<br/>$title6:'; } if (!empty($title7)) { $message .= '<br/>$title7:'; } if (!empty($title8)) { $message .= '<br/>$title8:'; } ?> And then, after the "// etc..." <?php $message .= "</th> </tr> <tr> <th>Price:</th> <th>$total </th> </tr> <tr> <th>Registrant:</th> <th>$name</th>"; ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197909 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 ok, so it is working now.........as you noticed, I had an image with it.......how can I place that as the background image in the email and make $price1-8 add together to show total price? Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197914 Share on other sites More sharing options...
searls03 Posted April 6, 2011 Author Share Posted April 6, 2011 now it also doesn't display subevent name.......... Quote Link to comment https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197918 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.