homepage Welcome to WebmasterWorld Guest from 54.204.168.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
PHP setup question
RussellC

10+ Year Member



 
Msg#: 1099 posted 5:20 pm on Oct 22, 2002 (gmt 0)

I am just starting out with PHP. I installed PHP and mySQL in Windows today to work with IIS as a testing server. I got PHP working fine (it will pull dates from the server etc...) except when I try to send URL query strings to a PHP page. I think i might need to configure something else in php.ini or something.

Say i have a generic HTML form:

<form action="welcome.php" method="get">
First Name: <input type="text" name="firstname" /><br />
Last Name: <input type="text" name="lastname" /><br />
<input type="submit" value="Submit" />
</form>

Then on the php page I have:

<?php
echo( "Welcome, $firstname $lastname!" );
?>

It shows the querys in the url /welcome.php?firstname=*&lastname=*

But All I get is Welcome, ! on Submit.

Anyone have any ideas what I am doing wrong? Thanks.

 

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 1099 posted 5:23 pm on Oct 22, 2002 (gmt 0)

you can only use those types of vars to echo if you have register_globals on.

try this

echo( "Welcome, $HTTP_GET_VARS["firstname"] $HTTP_GET_VARS["lastname"]!" );

RussellC

10+ Year Member



 
Msg#: 1099 posted 5:30 pm on Oct 22, 2002 (gmt 0)

Thanks for the reply.
That gave me this error:

Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in c:\inetpub\wwwroot\welcome.php on line 7
I even tried it like this:
echo( "Welcome to our Web site, " . $firstname . $lastname . "!" );
Didn't work either.

Also, register_globals = On in my php.ini.

[edited by: RussellC at 5:34 pm (utc) on Oct. 22, 2002]

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 1099 posted 5:33 pm on Oct 22, 2002 (gmt 0)

what version of php is it?

RussellC

10+ Year Member



 
Msg#: 1099 posted 5:34 pm on Oct 22, 2002 (gmt 0)

PHP 4.2.3

jatar_k

WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 1099 posted 5:36 pm on Oct 22, 2002 (gmt 0)

try this

echo "Welcome, " . $_GET["firstname"] . " " . $_GET["lastname"] . "!";

<added>missed a dot, sorry

dingman

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1099 posted 5:39 pm on Oct 22, 2002 (gmt 0)

try

echo( "Welcome, {$HTTP_GET_VARS['firstname']} {$HTTP_GET_VARS['lastname']}!" );

The {} lets PHP know to interpolate the array reference correctly. using "'" instead of '"' for the array key string avoids any possibility of your string being interpretted as ending at the '['.

If you're using a recent version of PHP, you might want to use $_GET instead of $HTTP_GET_VARS. $HTTP_GET_VARS is deprecated and may be removed in the future.

<added>Jatar_k's last approach ought to work, too.</added>

[edited by: dingman at 5:41 pm (utc) on Oct. 22, 2002]

andreasfriedrich

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1099 posted 5:40 pm on Oct 22, 2002 (gmt 0)

I donīt mind which version you are running ;)

Try this

echo( "Welcome, $_GET[firstname] $_GET[lastname]!" );

I do actually. And I am slow.

Andreas

RussellC

10+ Year Member



 
Msg#: 1099 posted 5:42 pm on Oct 22, 2002 (gmt 0)

That gave me:

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in c:\inetpub\wwwroot\welcome.php on line 7

Bingo:
I just make a phpinfo.php file to look at the settings on my php.ini file and it looks like all of the stuff I changed in php.ini didnt really change. It says register_globals = Off and it shows my extensions directory as c:\php4 when it isn't. I have the php.ini file in C:\windows\. Why isnt it seeing my settings changes?

dingman

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 1099 posted 5:47 pm on Oct 22, 2002 (gmt 0)

Have you restarted the web server? I don't know about Windows and IIS, but you have to restart Apache after making changes to php.ini.

RussellC

10+ Year Member



 
Msg#: 1099 posted 5:51 pm on Oct 22, 2002 (gmt 0)

I took a new php.ini and edited re-edited it and stuck it back in c:\windows and then restarted to web server and now it works! The old php.ini must have gotten messed up or corrupted or something. Thanks for the help everyone! I love this forum.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved