2013-05-20 46 views
0

你好,我已經tryed幾個其他發佈補丁的,看看有什麼我做錯了,但它仍然不拉我的cron作業字符串傳遞變量變量PHP腳本Cron作業調用帶有不工作

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

這是我的Cron作業字符串,這是它的調用腳本。

$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; 
} 
?> 

其調用腳本,但不能figger如何獲得的變量傳遞這樣我就可以使用它的任何指向我朝着正確的方向或幫助我解決將是有益的感謝你的幫助。

確定這是我固定的謝謝所有幫助

$mymethod = $_SERVER['argv']; 
$arrmethod = $mymethod[1]; 
parse_str($arrmethod); 
echo $method; 
+0

http://php.net/manual/reserved.variables.argv.php – DaGardner

+0

剛剛看到它在10分鐘內,現在我會看到,如果我的變化工作 –

+1

看看http://php.net/ getopt – bwoebi

回答

0

發出定額發佈的修改。