problems with PHP URL string variables

Web page creation, programs, scripts, PHP, SQL?

Moderator: Moderators

Postby darenwilko » Tue Aug 10, 2004 12:22 am

Hey,

If I call a file with the URL "http://127.0.0.1/test.php?numberOne=12" which holds a very simple script:

<?php
print("$numberOne");
?>

The result is an empty screen.

Why is this? can anyone tell me how to solve this problem, it worked fine on older versions of php?
Thanks for your help
darenwilko
 

Postby DenisF » Tue Aug 10, 2004 3:22 am

Look up 'register globals' on php.net
Image
[ FAQ ] :: [ Policy ] :: [ Port Forwarding Guide ] :: [ Search ]
User avatar
DenisF
Forum Admin
Forum Admin
 
Posts: 679
Joined: Mon Dec 16, 2002 9:09 pm
Location: Israhell

Postby darenwilko » Tue Aug 10, 2004 7:51 am

hey ive checked out the section... i must be so dumb (im not very good at php) i cant make any sense of it :S

Would you be able to demonstrate this to me if possibe?...

That would be great :)

Thanks
darenwilko
 

Postby DenisF » Tue Aug 10, 2004 8:30 am

Basicly, register globals is evil, and turned off on any new release of php.
[including my server, mandrake]

you should use superglobals instead, there's a short manual here;
<a href='http://www.php.net/manual/en/language.variables.predefined.php' target='_blank'>http://www.php.net/manual/en/language.vari....predefined.php</a>
Image
[ FAQ ] :: [ Policy ] :: [ Port Forwarding Guide ] :: [ Search ]
User avatar
DenisF
Forum Admin
Forum Admin
 
Posts: 679
Joined: Mon Dec 16, 2002 9:09 pm
Location: Israhell

Postby darenwilko » Tue Aug 10, 2004 10:28 am

thanks man i got it...

<HTML>
<HEAD>
<TITLE>test</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<?
$numberOne = $HTTP_GET_VARS['numberOne'];
echo "$numberOne <br>";
?>
</BODY>
</HTML>

im learning yay :D
darenwilko
 


Return to Web development

Who is online

Users browsing this forum: No registered users and 9 guests

cron