GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Jan-2002, 20:47
nniehoff nniehoff is offline
Member
 
Join Date: Aug 2001
Location: US
Posts: 115
nniehoff has a spectacular aura about

PHP variables


Lets say you have "something.php?mode=newhatever&blah=545"

How do you get the mode and blah variables out, is it easy? I know that using javascript you have to use a split method and a bunch of arrays, is it similar, or simpler?
Nick
  #2  
Old 10-May-2002, 06:28
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
I know this has been here for ages, and I only joiined yesterday, but I'll reply anyway. Just in case someone else has this problem.

The biggest advantage of PHP is the way that it handles variables, passed from one page to another. Put simply, your query string

"something.php?mode=newhatever&blah=545"

will create new variables in something.php called

$mode - which contains "newhatever"
$blah - contains "545"

It's that easy. Then you can do what you want to these variables from the start of something.php. Don't you just love Open Source!

Garth Farley
  #3  
Old 10-May-2002, 10:55
Andrew Andrew is offline
Member
 
Join Date: May 2002
Location: Yarm, Teesside, England
Posts: 145
Andrew will become famous soon enough
so you can then do something like:

echo"$mode";

and it will display:

newwhatever

__________________
Andrew
  #4  
Old 11-May-2002, 10:19
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Yup. Have a space between echo and the quote.

This should work too:

echo $mode;

Garth Farley
  #5  
Old 05-Jun-2002, 03:24
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
With php 4.2.1 it's now

PHP Code:

<?php
  echo $_POST['mode'];  // when the POST method (a form) is used
  echo $_REQUEST['blah'];  // if you're not certain
  echo $_GET['mode']; // when the GET method (query string) is used
?>



and they're superglobals, so they exist even in functions and classes!
  #6  
Old 08-Jun-2002, 07:26
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Yeah, that's been done for security reasons. There is a setting in PHP.ini that allows you to use the easier (if not a little more dangerous) variables. I think it's register_globals.

Garth Farley
  #7  
Old 24-Jul-2002, 06:46
nickbeee's Avatar
nickbeee nickbeee is offline
Junior Member
 
Join Date: Aug 2001
Location: Nottingham, UK
Posts: 80
nickbeee is on a distinguished road
Quote:
Yeah, that's been done for security reasons. There is a setting in PHP.ini that allows you to use the easier (if not a little more dangerous) variables. I think it's register_globals.

I just discovered that recently, couldn't figure out why PostNuke would not get past the first page of the installer on php 4.2.1 when it was perfect on 4.0.6 No choice but to use the register_globals workaround :-?

So much for upgrades

NickBeee
  #8  
Old 26-Jul-2002, 06:25
nickbeee's Avatar
nickbeee nickbeee is offline
Junior Member
 
Join Date: Aug 2001
Location: Nottingham, UK
Posts: 80
nickbeee is on a distinguished road
php 4.2.2 has been released as a security update.
http://www.php.net
 
 

Recent GIDBlog2nd Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error Pages BobbyDouglas MySQL / PHP Forum 118 17-Mar-2004 04:18
Optimizing your web server with Turck MMCache for PHP JdS Web Hosting Forum 2 07-Jan-2004 07:48
apache2 - php cgi fehler - schleife inna Apache Web Server Forum 8 27-Nov-2003 09:55
[Linux] Installing PHP --with-mcrypt JdS Web Hosting Forum 0 20-Aug-2003 08:40
All the big PHP script collections that matter jrobbio MySQL / PHP Forum 5 06-Jun-2003 16:14

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:12.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.