2014-03-24 15 views
0

任何人都知道我为什么会收到以下错误消息?解析错误:语法错误,/ usr/local/4admin/apache/vhosts中的意外T_STRING/

Parse error: syntax error, unexpected T_STRING in /usr/local/4admin/apache/vhosts/abmhd.com/httpdocs/Forms/Email.php on line 11 " Line 11 is " $recipient = "[email protected] "

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$call = $_POST['call']; 
$website = $_POST['website']; 
$priority = $_POST['priority']; 
$type = $_POST['type']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website:   $website \n Priority: $priority \n Type: $type \n Message: $message"; 
$recipient = "[email protected]<script type="text/javascript"> 
/* <![CDATA[ */ 
(function(){try{var  s,a,i,j,r,c,l,b=document.getElementsByTagName("script");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a) {s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2) {c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); 
/* ]]> */ 
</script>"; 
$subject = "Contact Form"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
echo "Thank You!"; 
?>` 
+0

转义$收件人中的双引号var – Danijel

+3

快速查看你的问题的颜色应该给你一个提示;) –

+0

$ formcontent缺少一个结束报价。 – j08691

回答

1

你应该逃避这样的:

$recipient = "[email protected]<script type=\"text/javascript\"> 

和变量定义中的一样为人人“

或者,也许更容易改变外双引号单者。

0

您需要为标签(也是js cod内部的引号) e):

<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$phone = $_POST['phone']; 
$call = $_POST['call']; 
$website = $_POST['website']; 
$priority = $_POST['priority']; 
$type = $_POST['type']; 
$message = $_POST['message']; 
$formcontent=" From: $name \n Phone: $phone \n Call Back: $call \n Website:   $website \n Priority: $priority \n Type: $type \n Message: $message"; 
$recipient = "[email protected]<script type=\"text/javascript\"> 
/* <![CDATA[ */ 
(function(){try{var  s,a,i,j,r,c,l,b=document.getElementsByTagName(\"script\");l=b[b.length-1].previousSibling;a=l.getAttribute('data-cfemail');if(a) {s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2) {c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})(); 
/* ]]> */ 
</script>"; 
$subject = "Contact Form"; 
$mailheader = "From: $email \r\n"; 
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); 
echo "Thank You!"; 
?> 

另外,用引号括住变量是很好的做法。

+0

嘿家伙,我尝试了所有的建议。 ..没有任何工作!我会很感激您可能会想到的任何其他方式。 –

相关问题