我的主要内容页面上的PHP错误 [英] PHP Error on my Primary content page

查看:100
本文介绍了我的主要内容页面上的PHP错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的课程在php网站上工作.我目前正在学习和理解开关代码,以及它如何利用菜单键索引.由于某种原因,我在页面第24行D:../../../../index.php中的注意:未定义的索引:menukey"上不断收到此错误.但是,一旦选择其他页面,即使单击主页链接,该错误也会消失.以下是我的index.php第24行的代码.有人可以照耀一下吗?

第24行-47

I''m working on a php website for my class. I''m currently in the process of learning and understanding the switch code, and how it utilizes the menukey index. For some reason I keep getting this error on my page "Notice: Undefined index: menukey in D:../../../../index.php on line 24". However once you select a different page the error goes away, even if you hit the home link. Below is the code from line 24 of my index.php. Could someone please shine some light on this?

Line 24 - 47

<?php switch ($_GET[''menukey'']) {<br mode="hold" /?>
  case 1:
    include "div/primarycontent.php";
    break;
						
  case 2:
    include "contactus.php";
    break;
					
  case 3:
    include "services.php";
    break;
						
  case 4: 
    include ("http://store.apple.com/us");
    break;
						
  default:  // case else
    include "div/primarycontent.php";
    break;
					
}
?>

推荐答案

_GET [''menukey'']){< br mode ="hold"/?> 情况1: 包括"div/primarycontent.php"; 休息; 情况2: 包括"contactus.php"; 休息; 情况3: 包括"services.php"; 休息; 情况4: 包括("http://store.apple.com/us"); 休息; 默认值://其他情况 包括"div/primarycontent.php"; 休息; } ?>
_GET[''menukey'']) {<br mode="hold" /?> case 1: include "div/primarycontent.php"; break; case 2: include "contactus.php"; break; case 3: include "services.php"; break; case 4: include ("http://store.apple.com/us"); break; default: // case else include "div/primarycontent.php"; break; } ?>


您需要显示带有用于访问此主要内容页面"的菜单的HTML代码,或者使用AJAX调用(如果使用的话)显示菜单,但基本上问题很简单:

PHP变量_GET是使用HTTP方法"get"的表单数据的关联容器,该方法由分别表示name属性的键索引.您的HTML代码中可能没有属性name="menukey",因此它不会出现在HTTP请求获取"数据中.

有关简单的示例和帮助页面,请参见 http://www.w3schools.com/php/php_get.asp [ ^ ].

您确定使用获取"吗?也许您使用发布"或其他方法,或者没有方法.例如,如果您使用"post",则应该使用PHP _POST,请参见 http://www.w3schools. com/php/php_post.asp [^ ].

如果仍然无法解决问题,请尝试发布一些表示HTTP请求"get"的HTML/JavaScript代码,该请求会尝试加载此页面.尝试使代码示例尽可能简单;请使用上方的改善问题".



好的,我看了看您的额外代码.不幸的是,"topmenu.php"中没有提及"menukey".它在此文件的任何地方吗?如果没有,您希望它如何工作.同样,按整数切换是非常糟糕的.它不可读且不受支持.

请不要发布您的代码作为解决方案-事实并非如此.没有人会收到电子邮件通知,该帖子将被删除.我要求您改用改善问题".

—SA
You need to show the HTML code with menu you use to get to this "primary content page" or your AJAX call if you use any, but basically the problem is simple:

The PHP variable _GET is an associated container of form data using HTTP method "get" indexed by keys each representing a name attribute. You probably don''t have an attribute name="menukey" in your HTML code, so it does not appear in your HTTP request "get" data.

For a simple sample and a help page, see http://www.w3schools.com/php/php_get.asp[^].

Are you sure you use "get"? Perhaps you use "post", or something else, or no method. For example, if you used "post", you should have used PHP _POST, see http://www.w3schools.com/php/php_post.asp[^].

If it doesn''t make things clear for you, please try to post some HTML/JavaScript code representing HTTP request "get" which tries to load this page. Try to make a code sample as simple as possible; use "Improve question" above.



OK, I took a look at your extra code. Unfortunately, there is no mention of "menukey" in "topmenu.php". Is it anywhere in this file? If not, how would you expect this to work. Also, a switch by integer number is pretty bad. It is not readable and supportable.

Please do not post your code as solution — it is not. No one will get e-mail notifications, the post will be removed. I asked you to use "Improve question" instead.

—SA


这篇关于我的主要内容页面上的PHP错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆