duanlinghe8417 2014-10-17 09:26
浏览 27
已采纳

PHP SESSION VAR存在但PHP消息:PHP注意:

I'm getting this error:

[17-Oct-2014 08:46:12] WARNING: [pool blah.com] child 43657 said into stderr: 
"NOTICE: PHP message: PHP Notice:  Undefined index: database_geo in /var/blah/site_profile.class.php on line 124"

The error is for the following code and I've put a var_dump() in front of it with the session var:

print '<pre>';
var_dump($_SESSION['database_geo']);
print '</pre>';

    // GEO Distance between Members in KM or Miles
    if($this-true) {
        $sql='SELECT la,b FROM geoWorld WHERE pid=? LIMIT 1;';
        $pds=$database->pdo->prepare($sql); $pds->execute(array($_SESSION['database_geo'])); $row=$pds->fetch();
        $this->geoDistanceToMe = $location->geoDistanceBetweenMembers($this->profileLatitude,$this->profileLongitude,$row['latitude'],$row['longitude'],FALSE);
    }

The page displays fine but the error shows. I can see the variable "$_SESSION['database_geo']" exists as it display sin the var_dump().

Is there any reason why this message would appear of the var exist?

thankyou - confused...

  • 写回答

1条回答 默认 最新

  • duan5801 2014-10-17 09:38
    关注

    Use session_start() before entering or getting something from $_SESSION. See this link http://php.net/manual/ro/function.session-start.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献