-1

Hello i have tryed a few of the other posting fixes to see what i am doing wrong but its still not pulling the variable passed in my cron job string

php -q public_html/conquest/update_power_server.php method=Password

That is my Cron Job String and this is the script its calling.

    $mymethod = $_SERVER['argv'];
$method = $mymethod[1];

$con=mysqli_connect("localhost", $user_name, $password, $database_name);
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  echo $method;
if($method == $scpassword)
{

  $result = mysqli_query($con,"SELECT * FROM `$table_name` WHERE energy < 30");

while($row = mysqli_fetch_array($result))
  {
   $uuid = $row['uuid'];
   $newenergy = $row['energy'] + 1;
   mysqli_query($con,"UPDATE `$table_name` SET energy = '$newenergy' WHERE uuid = '$uuid'");
  }

mysqli_close($con);
exit;
}else{
echo ("Access Denied!!!");
exit;
}
?>

Its calling the script but cant figger out how to get the variable to pass so i can use it any help pointing me in the right direction or helping me fix would be helpful thank you.

4
  • php.net/manual/reserved.variables.argv.php Commented May 20, 2013 at 14:30
  • yea just seen it in 10 min from now i will see if my changes work Commented May 20, 2013 at 14:33
  • 1
    have a look at php.net/getopt Commented May 20, 2013 at 14:35
  • You do know you can just use a single statement? Commented May 20, 2013 at 14:48

1 Answer 1

0

This is how I fixed it:

$mymethod = $_SERVER['argv'];
$arrmethod = $mymethod[1];
parse_str($arrmethod);
echo $method;
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.