Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » errors unexpected t_string using php mail function
Closed Thread
Old 03-10-2006, 11:01 AM   #1 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default errors unexpected t_string using php mail function

PHP Code:
<?php

foreach ($_POST as $key => $value
  
$message $message.$key." - ".$value."\r\n";

$headers 'From: ' $_POST["Email"] . "\r\n" .
   
'Reply-To: ' $_POST["Email"] . "\r\n" .
   
'X-Mailer: PHP/' phpversion();

//echo $message;

if mail("email@domain.com""Contact Us Page"$message$headers)
  echo 
"Your email has been successfully sent

[url='/contact_us.htm']Click here[/url] to return to the previous page."
;
else
  echo 
"There was an error while trying to send the email.  Please call us at xxx.";

?>
when entering multiple lines for my Comments field i get a unexpected t_string error when trying to use the mail function

here's the commented echo $message output:

First_Name - c Last_name - samuels Company - fos Street - 125 west broadway City - salem State - nj ZipCode - 08079 Policy - test Telephone - 123-456-7890 Email - email@domain.com Comments - test another line and another and another B1 - Submit
office politics is offline  
Old 03-10-2006, 04:35 PM   #2 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default

don't you need to enclose the predicate for the IF statement in ()
__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
Old 03-10-2006, 04:42 PM   #3 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default

only if you want multiple statements to run

i have this code that works. it is a part of an unrelated script

PHP Code:
function insert($x$stack$table) { 
$query "insert into ".$table." set ";//move data into table
for ($i=0;$i<$x;$i+=2) {
  if (
substr(pos($stack), 04) == "com_"// is field name prefixed with com_?
    
$query $query.substr_replace(pos($stack),"",0,4)."='";//Shave com_ & Add field name to the query
  
else 
    
$query $query.pos($stack)."='";//Get field name & add it to the query
  
next($stack);//Move to data entry
  
if(is_array(pos($stack))) { //Is data entry from checkboxes?
    
foreach(pos($stack) as $element// Each checkbox entry
      
$query $query.$element.","//gets added to the query
    
$query$query."',";//finish query
  
}  
  else 
    
$query$query.pos($stack)."',";//Get data entry & add it to the query
  
next($stack);//Get next field name
  //echo $i."
";


office politics is offline  
Old 03-15-2006, 11:12 AM   #4 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,410

office politics will become famous soon enough

Default

Quote:
Originally posted by TheHeadFL
don't you need to enclose the predicate for the IF statement in ()
im sorry, you're correct. i needed to enclose the mail function in (). Here's the working code.

PHP Code:
<?php

foreach ($_POST as $key => $value
  
$message $message.$key." - ".$value."\r\n";

$headers 'From: ' $_POST["Email"] . "\r\n" .
   
'Reply-To: ' $_POST["Email"] . "\r\n" .
   
'X-Mailer: PHP/' phpversion();

//echo $message;

if (mail("email@domain.com""Contact Us Page"$message$headers))
  echo 
"Your email has been successfully sent

[url='/contact_us.htm']Click here[/url] to return to the previous page."
;
else
  echo 
"There was an error while trying to send the email.  Please call us at xxx.";

?>

office politics is offline  
Old 03-15-2006, 06:38 PM   #5 (permalink)
 
Ultra Techie

Join Date: Jul 2005

Posts: 530

TheHeadFL

Send a message via AIM to TheHeadFL
Default


__________________
Desktop machine: 2 x Opteron 246, Asus K8N-DL, 2GB PC3200 ECC Reg., XFX GeForce 6600GT, 74gb WD Raptor, 2 x 19\" LCDs, Windows XP x64
Server machine: Intel P4 3.0GHz 2MB EM64T, ECS i865pe, 1GB PC3200, 36gb WD Raptor, Windows Server 2003
Laptop: Dell Inspiron 9100 (Intel P4 3.2GHz 1MB Prescott, i865pe, 512MB PC3200, Mobility Radeon 9700, DVD+R/DL Burner), Windows XP
Linux: P3 450Mhz, 386MB ram, Slackware 10.1 (Running mySQL/Apache)
TheHeadFL is offline  
 
Closed Thread

Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On