I want to input id number and date as command line arguments for a pHP script that sends query to the database.
I am using a version PHP/4.2.2
My script starts as follows:
<?php
$num_args= $SERVER['argc'];
$argv= $
SERVER['argv'];
echo $argc"\n";
echo $argv[0];
Then I have my query script etc
?>
it is stored in script.php.
Then when I run my code in linux command line,
php script.php 2 1 '2004-01-28%'

I get the following error.
PHP Notice: Undefined index: argc script.php on line 3
PHP Notice: Undefined index: argv script.php on line 4
How should I correct this?
Thanks,
balaji.

    I use this and it works fine

    <?php

    $argc = $SERVER["argc"];
    $argv = $
    SERVER["argv"];

    ...

    ?>

      You try just $argv and $argc? Those variables might be setup for you automatically. If you're still stuck, do phpinfo() and look towards the end of the output and find the data command line arguments you entered and see which variable is holding them...

        Write a Reply...