2012-10-22 56 views
-4

PHP新手。不断收到PHP代码中出现意外错误

Parse error: syntax error, unexpected T_ECHO

我的代码。

<?php 
header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token=' echo $client['id']); 
?> 

无法弄清楚语法错误是什么。谢谢。

+0

请显示您的代码以便于查找错误。 – Prem

+0

欢迎来到Stackoverflow。请在发布*任何*问题之前,按照您需要确认的[问题建议](http://stackoverflow.com/questions/ask-advice)进行确认。请记住,只有你想要的东西,你问自己如何编程不符合本身的编程问题。例如搜索之前问:http://stackoverflow.com/search?q=%5Bphp%5D+Parse+error%3A+syntax+error%2C+unexpected+T_ECHO - 并看看右边,**相关**栏。 – hakre

+0

也请看看这个参考问题,你可能会发现这有帮助:http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php – hakre

回答

1

你必须串联值:

<?php 
header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token=' . $client['id']); 
+0

我会说如果错误消息对于OP来说太复杂了,您的答案存在问题,因为代码示例需要滚动。 ;) – hakre

2

在你行的最后,您有:

echo $client['id']); 

你试图追加$client['id']到URL,因此将其删除echo并将其替换为.

header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token=' . $client['id']); 
0

试试这个

<?php 
header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token='.$client['id']); 
?> 
0
header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token='.$client['id']); 
0

当你想将字符串不要使用echo,您使用.(点)。因此请将您的header行更改为:

header('Location: http://www.dcaccountancyservices.com/index.php?option=com_chronoforms&tmpl=component&chronoform=EditClient&token='.$client['id']);