我在PHP &MySQL应用程序从Joomla和Jomsocial:
[05-Apr-2013 12:23:45 America/Denver] PHP Notice: Undefined index: query in /home2
/robervl4/public_html/forum/components/com_community/community.php on line 50
此操作无法开箱运行。应用程序显示了数据库中的产品,唯一的问题是我得到了这个错误。
下面是该文件的PHP代码,第50行是:parse_str($parts['query'], $qstring);
代码:// DISABLE FORMAT=FEED for now 17Jan13 as requested by Fuqaha
$mainframe = JFactory::getApplication();
$jinput = $mainframe->input;
$viewType = $jinput->request->get('format', 'html','NONE');
if(strtolower($viewType)=='feed') {
$u = JFactory::getURI();
$parts = parse_url($u->toString());
parse_str($parts['query'], $qstring);
unset($qstring['format']);
$parts['query'] = http_build_query($qstring) ;
//recompose the URL to redirect
$scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
$host = isset($parts['host']) ? $parts['host'] : '';
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? '?' . $parts['query'] : '';
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
$mainframe->redirect(CRoute::_("$scheme$host$port$path$query$fragment"));
exit('Redirecting to Non-Feed page');
}
parse_url
仅在具有值时才包含索引。即,如果没有查询,则不设置$parts['query']
。测试是否先设置:if (isset($parts['query'])) parse_str($parts['query'], $qstring);
parse_url可能不包含查询字段。只有当URL中存在查询部分时,它才包含查询字段;所以首先检查$parts["query"]是否存在(isset())