Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

noob query

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

noob query

Postby flash_harry » Thu Jan 30, 2003 2:11 am

Any ideas why i'm gettin this error

PHP Notice: Undefined variable: name in c:\inetpub\wwwroot\test10.php on line 10

for this script

2 <html>
3 <head>
4 <title>Untitled Document</title>
5
6 </head>
7
8 <body>
9 <?php
10 if($name !="")
{
echo"<p align = 'left'><b><i>$name</b></i></p>";
}
?>
<a href="test10.php?name=one">One</a><br>
<a href="test10.php?name=two">Two</a>

</body>
</html>
flash_harry
New php-forum User
New php-forum User
 
Posts: 26
Joined: Thu Jan 16, 2003 6:05 am

Postby pootergeist » Thu Jan 30, 2003 5:04 am

are you passing the value as a url query string?

you might want to upgrade your variable references to account for super global arrays

if(isset($_GET['name']) && $_GET['name'] !== "")
{
// name=value exists in the url, so do stuff.

}

Older versions of PHP would use $HTTP_GET_VARS['name']
pootergeist
New php-forum User
New php-forum User
 
Posts: 191
Joined: Wed Jan 29, 2003 7:11 am
Location: UK

Postby flash_harry » Thu Jan 30, 2003 5:25 am

Nice one.
Worked a treat.

You are the man! 8)
flash_harry
New php-forum User
New php-forum User
 
Posts: 26
Joined: Thu Jan 16, 2003 6:05 am


Return to PHP coding => General

Who is online

Users browsing this forum: Google Feedfetcher and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.