-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.

Pang
  • 9,564
  • 146
  • 81
  • 122

1 Answers1

0

This is how I fixed it:

$mymethod = $_SERVER['argv'];
$arrmethod = $mymethod[1];
parse_str($arrmethod);
echo $method;
Pang
  • 9,564
  • 146
  • 81
  • 122