Running php code locally passing parameters not working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Wootah
Forum Newbie
Posts: 13
Joined: Wed Jul 14, 2010 7:08 pm

Running php code locally passing parameters not working

Post by Wootah »

Hi all,

I open the cmd prompt and run a php script and it works. Ex: php script.php

I was hopeful I could use the querystring parameter Ex: php script.php?var1=A&var2=B

But I get: Could not open input file: ExtractOneDatabase.php?dbid=5

Is there a way to do this? Or do I need to pass parameters via an input file when run locally?

Thanks,

Mat
Wootah
Forum Newbie
Posts: 13
Joined: Wed Jul 14, 2010 7:08 pm

Re: Running php code locally passing parameters not working

Post by Wootah »

So far I have found:

var_dump($argv);
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Running php code locally passing parameters not working

Post by AbraCadaver »

Yes $argv will give you the parameters that were passed. If you want to use the query string as you have shown then you would do something like:
[text]php script.php var1=A&var2=B[/text]

Code: Select all

parse_str($argv[1]);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply