Jump to content

Recommended Posts

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.";

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1196884
Share on other sites

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");

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197206
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197435
Share on other sites

$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.....

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197461
Share on other sites

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



?>

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197546
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197556
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197887
Share on other sites

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

 

Link to comment
https://forums.phpfreaks.com/topic/232693-mail-function/#findComment-1197909
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.