Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 9 votes, 3.44 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-02-2002, 04:23 PM   PM User | #1
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
Passing String with URL Problem?

im atempting to learn PHP and iv ran into a situation...

Im running apache web server with php and mySQL...This question has nothing to do with mySQL but....

I Created a file called welcome.hml and included the following code...

<html>
<head>
<title>Welcome</title>
</head>

<body>

<Font color = "Black">
<a href="http://localhost/welcome.php?name=Dave"> Hi, I'm Dave!</a>

</body>

</html>

Then i created a filed called welcome.php and included this code...

<html>
<head>
<title>Welcome</title>
</head>

<body>

<?php
echo( "Welcome to our web site, $name!" );
?>

</body>

</html>

and then i goto http://localhost/welcome.html and click on the link and it takes me to welcome.php but heres the problem...

The output on welcome.php says:
Welcome to our web site, !

It doesnt pass the name dave to the page from the URL whats causing that... I got the code straight from a book...

I know php is working cause i used it witha date function and it worked fine
Squintz is offline   Reply With Quote
Old 08-02-2002, 05:02 PM   PM User | #2
SYP}{ER
Regular Coder

 
Join Date: Jun 2002
Location: Ontario, Canada
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
SYP}{ER is an unknown quantity at this point
Weird... Do you have register_globals turn ON in the php.ini file?

If not, you'll have to use this:

<?="Welcome to our web site, ".$_GET['name']."!"?>
__________________
Offtone.com - In the works...
SYP}{ER is offline   Reply With Quote
Old 08-02-2002, 05:06 PM   PM User | #3
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
yes their turned on...Im not even sure where to look for the problem... so any input will help thanx
Squintz is offline   Reply With Quote
Old 08-02-2002, 05:10 PM   PM User | #4
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
i put that code you said in and it did work yet globals are turned on
Squintz is offline   Reply With Quote
Old 08-02-2002, 05:13 PM   PM User | #5
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
i wonder...Is the file supposed to be php.ini or php.ini-dist which is what its named....Also when i make changes to i need to restart apache and if so whats the proper way to shut down apache and restart it
Squintz is offline   Reply With Quote
Old 08-02-2002, 05:17 PM   PM User | #6
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
Ok i renamed the file and now it works... i changed it from php.ini-dist to php.ini....Im not sure where the -dist came from....

Thanx for your help
Squintz is offline   Reply With Quote
Old 08-02-2002, 05:27 PM   PM User | #7
Centaur
New to the CF scene

 
Join Date: Jul 2002
Location: Novosibirsk, Russia
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Centaur is an unknown quantity at this point
dist means distribution, that&rsquo;s the default template which you are supposed to copy and modify.

And one advice: leave register_globals off and get a habit of accessing arguments via $_GET and $_POST, this will prevent the situation when you expect a variable to be empty yet someone passes you a value through the query string.
Centaur is offline   Reply With Quote
Old 08-02-2002, 07:32 PM   PM User | #8
Squintz
Regular Coder

 
Join Date: Jul 2002
Posts: 226
Thanks: 0
Thanked 0 Times in 0 Posts
Squintz is an unknown quantity at this point
thanx for the advice...
Squintz is offline   Reply With Quote
Old 08-06-2002, 08:31 PM   PM User | #9
SYP}{ER
Regular Coder

 
Join Date: Jun 2002
Location: Ontario, Canada
Posts: 183
Thanks: 0
Thanked 0 Times in 0 Posts
SYP}{ER is an unknown quantity at this point
Plus more and more hosts will eventually be switching register_globals off so your scripts may fall apart on some new-age host
__________________
Offtone.com - In the works...
SYP}{ER is offline   Reply With Quote
Old 08-07-2002, 05:54 PM   PM User | #10
skinme!
New Coder

 
Join Date: Jul 2002
Location: London, UK
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
skinme! is an unknown quantity at this point
But, if you have a html template loading data to show as text depending on say $page:

index.php?page=home

then users won't be able to bookmark your pages. Not totally relevant but I think that hosts turning it off in the ini is not very helpful.
__________________
skinme.net / v2.php (design nearly completed)
skinme! is offline   Reply With Quote
Old 08-07-2002, 06:29 PM   PM User | #11
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
index.php?page=home

will still work for the user, the only difference is that your script will have to do this (just guessing what $page does here)

include('/home/httpd/include/$_GET[home].php');
instead of this
include('/home/httpd/include/$home.php');

register_globals only changes how we access the varibles nothing else
__________________
resistance is...

MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)
firepages is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:32 AM.


Advertisement
Log in to turn off these ads.