Re: i need help with an undefined variable
| From: | Luis Ferro | Date: | Wed, 02 Oct 2002 21:28:53 +0000 |
| Subject: | Re: i need help with an undefined variable | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-16134@lists.php.net to get a copy of this message | ||
You should test first for the existence of the var before using it...
a better code would be:
<?php
@include("head.html");
if (!isset($_GET["game"])) {
@include("public.html");
}
?>
You should test for the existence of the var instead of using it's value in a condition... otherwise you will get a warning for each that you use without a previous definition...
Cheers...
Luis Ferro
<?php
include("head.html");if (isset()
Peter Houchin wrote:if (!$_GET["game"]) { include("public.html"); } if ($_GET["game"] != NULL && $op != NULL) { include("http://mywebsite.com/example/" . "$game" . ".html"); }
have u tried using $_GET["game"] or $_POST["game"] ? so your code is <?php--- [This E-mail scanned for viruses by Declude Virus]or post instead of get in there?include("head.html"); if (!$_GET["game"]) { include("public.html"); } if ($_GET["game"] != NULL && $op != NULL) { include("http://mywebsite.com/example/" . "$game" . ".html"); }-----Original Message----- From: Anyang [mailto:anyang@optonline.net] Sent: Wednesday, 2 October 2002 1:43 PM To: php-windows@lists.php.net Subject: Re: [PHP-WIN] i need help with an undefined variable Like i said, the other server understood it at a function of the address bar so if index.php?game=foobar then $game = foobar and it would refresh the page with the foobar page in the center. This is what I want to do. "Peter Houchin" <php@vfsa.com.au> wrote in message news:DPEPKCNEFOKBCNNANCIPAEADCNAA.php@vfsa.com.au...host and ithow r u getting $game? that's the undefind var.-----Original Message----- From: Anyang [mailto:anyang@optonline.net] Sent: Wednesday, 2 October 2002 11:38 AM To: php-windows@lists.php.net Subject: [PHP-WIN] i need help with an undefined variable I wrote a php script for a page that I hosted on a separatebuildworked perfectly. I recently installed php 4 onto my windows XP Prothe2600 computer and it seems to work until I try to use varuables that look to the address bar for reference. I wanted to make it so that when somebody clicks "game" it would go to www.mywebsite.com/index.php?game=example and that would merely replaceC:\Xitami\webpages\index.php on line 5body with the example page. It worked on my other host but when I tried it on my computer it says: Notice: Undefined variable: game inC:\Xitami\webpages\index.php on line 8Notice: Undefined variable: game in-- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpMy script says: <?php include("head.html"); if (!$game) { include("public.html"); } if ($game != NULL && $op != NULL) { include("http://mywebsite.com/example/" . "$game" . ".html"); } any ideas? please help. if there's any script i can type and have all the pages require it so that this can be defined that would work great. -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php