[PHP] Passing Variables from Script to Script

2006-04-08 Thread Alan Schneider
What is the best way to pass a variable value from one script to another?

In unix or dos all I would need to do would be to add them just after the
name of the script

such as myscript.bat  

thanks

Alan

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passing Variables from Script to Script

2006-04-08 Thread Richard Lynch
PHP has those variables in $argv

$argc tells you how many args there were.

$argv[0] is the actual script name, eg, myscript.php



On Sat, April 8, 2006 2:58 pm, Alan Schneider wrote:
 What is the best way to pass a variable value from one script to
 another?

 In unix or dos all I would need to do would be to add them just after
 the
 name of the script

 such as myscript.bat  

 thanks

 Alan

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Passing variables from script to script

2002-12-11 Thread Stefan Hoelzner
Hi folks,

surely this question has already been answered many times before in this ng, but 
nevertheless: I want to pass variables  from
one .php to another .php script. But I do not want to use either the 
http://localhost/target.php?var1=testvar2=test2 nor  
the
POST method. I would like to pass over general variables like usernames and passwords 
for several MySQL-connects;  obviously
it is not a good way to pass these vars via the mentioned ways.

What else does PHP offer? Are there any other methods? Can I define these vars as some 
kind of global variables in any
ini-file?

THX for your support!

Stefan.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Passing variables from script to script

2002-12-11 Thread Jason Wong
On Wednesday 11 December 2002 07:56, Stefan Hoelzner wrote:
 Hi folks,

 surely this question has already been answered many times before in this
 ng, but nevertheless: 

So why don't you search the archives to read the answers!?!

 I want to pass variables  from one .php to another
 .php script. But I do not want to use either the
 http://localhost/target.php?var1=testvar2=test2 nor the
 POST method. I would like to pass over general variables like usernames and
 passwords for several MySQL-connects;  obviously it is not a good way to
 pass these vars via the mentioned ways.

 What else does PHP offer? Are there any other methods? Can I define these
 vars as some kind of global variables in any ini-file?

Use sessions.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
OS/2 must die!
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Passing variables from script to script

2002-12-11 Thread bahwi
If they are static you could store them in another php file and include 
them.

HTTP is stateless, meaning one person can go from one page to another or 
log out in between all of this. It also means there is no authentication 
for users, you can not prove that one person is the same person the next 
time he visits the page.

Without using GET or POST. I would go with cookies. In fact, I would go 
with SESSIONS.
http://www.php.net/manual/en/ref.session.php

This way, only the session ID is stored as a cookie, and you can store 
the other variables on the server under $_SESSION['username'] and 
$_SESSION['password']. This may not be the perfect solution to your 
problem, but take a look. It's really useful. You have to run 
session_start(); before anything else, and it does it all via 
cookies(and sometimes through GET), but works very well in my experience.

You may also want to look at:
http://www.php.net/manual/en/function.ini-set.php

to control various aspects of PHP's sessions. I've found ini_set() with 
sessions to be invaluable. Hope this helps!

--Joseph Guhlin - http://www.josephguhlin.com/ 
Was I helpful?  Let others know:
http://svcs.affero.net/rm.php?r=bahwi






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passing variables from script to script

2002-12-11 Thread Philip Olson
On Tue, 10 Dec 2002, Stefan Hoelzner wrote:

 Hi folks,
 
 surely this question has already been answered many times before in
 this ng, but nevertheless: I want to pass variables from one .php to
 another .php script. But I do not want to use either the
 http://localhost/target.php?var1=testvar2=test2 nor the POST method.
 I would like to pass over general variables like usernames and
 passwords for several MySQL-connects;  obviously it is not a good way
 to pass these vars via the mentioned ways.
 
 What else does PHP offer? Are there any other methods? Can I define
 these vars as some kind of global variables in any ini-file?

Use includes.  http://www.php.net/include

dbinfo.inc
?php
  $host = 'localhost';
  $user = 'foo';
  $pass = 'bar';
  ...
?

showstuff.php
?php
  include 'dbinfo.inc';

  if (!$conn = mysql_connect($host, $user, $pass)) {
  ...
?

Ideally this include will be outside the document root.  If 
not, make sure it's not viewable or use a php extension such 
as .php  See also the include_path php directive.

Regards,
Philip


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Passing variables from script to script

2002-12-11 Thread Chris Hewitt
Stefan Hoelzner wrote:



nevertheless: I want to pass variables  from
one .php to another .php script. But I do not want to use either the http://localhost/target.php?var1=testvar2=test2 nor  
the
POST method. I would like to pass over general variables like usernames and 

Sessions. The data is stored on the server and only a session id 
transferred by cookie/post/get.

HTH
Chris


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Passing variables from script to script

2002-12-11 Thread Justin French
1. the only other ways to pass things around would be in sessions, or by
setting a cookie on the user's computer... i hate the latter, and would
prefer the former, but would NEVER carry things like a MySQL uname and
password around in cookies or sessions.  cookies, sessions, and even post 
get (url) should be used for user-specific things (who are they, what are
they asking the server to do), not program-related things (like the database
password, or the global font size, or the site admin's email address... this
is generally done with a config file or other included file:

2. you could define your vars (like the MySQL uname and pword) in a config
file, and include it at the top of all your PHP scripts:

? include('incdir/config.php'); ?
html
...
/html

3. you can extend this further, by setting a value php.ini (auto-prepend I
think) so that PHP will ALLWAYS includes the config file at the top of every
script.


Justin



on 11/12/02 10:56 AM, Stefan Hoelzner ([EMAIL PROTECTED]) wrote:

 Hi folks,
 
 surely this question has already been answered many times before in this ng,
 but nevertheless: I want to pass variables  from
 one .php to another .php script. But I do not want to use either the
 http://localhost/target.php?var1=testvar2=test2 nor
 the
 POST method. I would like to pass over general variables like usernames and
 passwords for several MySQL-connects;  obviously
 it is not a good way to pass these vars via the mentioned ways.
 
 What else does PHP offer? Are there any other methods? Can I define these vars
 as some kind of global variables in any
 ini-file?
 
 THX for your support!
 
 Stefan.
 
 

Justin French

http://Indent.com.au
Web Development  
Graphic Design



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php