dongrong9938 2013-01-28 23:44
浏览 39
已采纳

PHP会话功能调试辅助

I know how to include external PHP pages and how to start sessions etc, but I think there is something messed up with my logic on what I am working on. Hoping someone could take a look...

I have an html page that is a form that pulls up a PHP view page with the info it sends to it. I wanted to put my function in an external page, along with using sessions, but I keep getting a syntax error.

When I send my form it goes to the following:

<?php
session_start();
include 'functs.php'; 
if ($_POST && !empty($_POST['name'])) {
$_SESSION['name'] = $_POST['name'];
$_SESSION['time'] = $_POST['time'];
confirmed();
}
else {
print unconfirmed();
}
?>

My external page with the functions is this:

<?php
function confirmed() {
echo "<head>";
echo "<title>Confirmation Page</title>";
echo '</head>";
echo "<body>";

PRINT <<<HERE

if (isset($_SESSION['name'])) {
echo 'Thank you, '.$_SESSION['name']. ' your reservation is confirmed for ' . $_SESSION['time'] ;
}
else {
echo 'There seems to have been an error processing your reservation. Please ensure that  you have cookies enabled and try your request again' ;
}

HERE;

echo "</body></html>";
?>

The error I am getting is Parse error: syntax error, unexpected 'name' (T_STRING), expecting ',' or ';' in E:\Program Files\xampp\htdocs\cis\w2\functs.php on line 10. If I insert the function internally, it works, so I know its something with how I am formatting the include page.

  • 写回答

2条回答 默认 最新

  • duan0414 2013-01-28 23:47
    关注

    It's pretty obvious via the syntax highlighting what is wrong here:

    echo '</head>";
    //-----------^
    

    This line has the incorrect quote mark, thus you never terminate the string, and it keeps going.

    Edit:

    But that isn't the only problem. You also never close your function with a right curly bracket: }.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line