Wamp error on my first ever dynamic page, Help please!
Posted by: dannyscauser (92.17.217.---)
Date: January 12, 2011 11:48PM

Hi, I am trying to make my first dynamic site using php. I am however getting the following error message on my first page:
_______________________________________________________
My first Page
home
tutorials

Notice: Undefined index: page in C:\wamp\www\test\index.php on line 18
welcome to my website
______________________________________________________

my tutorial link works and doesnt display the error. but my index page makes this come up. my code is as follows(ive marked line 16 on here, not on my actual script)
_______________________________________________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[www.w3.org];
<html xmlns="[www.w3.org];
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Page</title>
</head>

<body>

<h1>My first Page</h1>

<a href="index.php">home</a><br />
<a href="index.php?page=tutorials">tutorials</a><br />



<?php
*****THIS IS LINE 16***** $page = $_GET['page'];

if ($page)

{
include ("content/".$page.".php"winking smiley;

}
else
{

echo "welcome to my website";
}


?>

</body>
</html>

______________________________________________________

Please help if you can, Im using wamp and firefox!

Options: ReplyQuote
Re: Wamp error on my first ever dynamic page, Help please!
Posted by: stevenmartin99 (---.251.255.12.threembb.ie)
Date: January 13, 2011 06:25AM

You are using an undeclared variable IF you load the page with out the get string at the end of the URL

The tutorial is not 100% correct , but you can just turn off these warning in the php settings under Error_reporting.

Really you should change the code to use the php functions empty() and isset() to check the variable is on the end of the URL before you tell php to set something that may not be there to set.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 01/13/2011 06:31AM by stevenmartin99.

Options: ReplyQuote


Sorry, only registered users may post in this forum.