Jump to content


Problem with $_GET


4 replies to this topic

#1 The Creator

    Young Padawan

  • Members
  • Pip
  • 115 posts
  • Gender:Male
  • Location:England
  • Interests:Computers, Music, Technology, Sport

Posted 05 December 2006 - 05:29 PM

k, heres my code (i also have other cases):

<?php

$page = $_GET['page'];

$id = htmlentities(trim($page), ENT_QUOTES);

switch($id) {

default: 

echo"

<table width='90%' border='0'>
	<tr>
	  <td width='55%' height='366'><img src='/new/images/ant04.jpg' width='525' height='350'></td>
	  <td width='45%'><div class='title'>Welcome 
		  to the official website of the
		  Antigua Marathon</div><br><br><div class='maincontent'>
		  This exciting event is being organised by <a href='janturner.html'>Jan 
		  Turner</a> in conjunction with The Antigua 
		  and Barbuda Sports Tourism Alliance
		 <a href='htttp://www.absta.com'>(ABSTA)</a> to promote, train and encourage 
		  runners from the West Indies to achieve their full potential on the 
		  international stage of long distance running.
		  We hope that it will promote the island as a holiday destination and will 
		  add to its calendar of sporting and cultural events.</h4>
		  We welcome participants from around the World for the inaugeral event which 
		  will take place on: 
		  Sunday 21th October 2007.</td>
	</tr>
  </table>
  <h4>&nbsp;</h4>
  <p align='left'>&nbsp; </p>
  <p>&nbsp;</p>
  <p><a href='http://www.barbadosjourneys.com/'><img src='/new/images/bbdosJ.gif' width='261' height='30' border='0'></a> 
  </p>


";

break;
?>

for some reason i get this message:

Quote

Notice: Undefined index: page in D:\webs\antiguamarathon.com\html\new\includes\page.php on line 3

can someone help me fix the problem?

thx


Joe

#2 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 05 December 2006 - 05:39 PM

Quote

NOTICE is not a real error. It is just a warning that you are using an undefined index in an array somewhere. I would just turn off notices in my php.ini file (set error reporting to all except notices, as someone posted before). You do not need to change your code.

Explains it better than i would. (apart from saying that you do not need to modify php.ini to turn off notices, it an be done using error_reporting(E_ALL ^ E_NOTICE); as you may not be able to edit php.ini)

Just an example of the wonders of Google for you

#3 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 05 December 2006 - 05:58 PM

Ya, PHP is simply telling you that the variable does not exist in the array (like matthewJ said). In other words, it couldn't find 'page' in the query string.
Notices are nothing to be concerned about unless you are 100% for the E_ALL complience, which I personally see no need for unless you believe PHP will make it mandatory later on or something. PHP is quite lenient, and I use that to my advantage alot, lol.

#4 The Creator

    Young Padawan

  • Members
  • Pip
  • 115 posts
  • Gender:Male
  • Location:England
  • Interests:Computers, Music, Technology, Sport

Posted 07 December 2006 - 02:43 PM

thanks guys, thats great!

if i dont actually solve the problem (the notice thing) does it leave my site unsecure or anything?

#5 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 07 December 2006 - 04:26 PM

In most cases, no.
The only reason I would think of that is if you were using a very sensitive variable to grab from or something that didn't exist and could crash the script if that variable was not set correctly. Thus why you always need to throughly parse and make sure incoming data is what it should be. :o
I honestly don't know alot of the notices that PHP issues, since I always have error_reporting in my ini directive to ignore them, lol.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users