无法将PHP脚本作为cron作业运行

时间:2017-10-11 11:25:31

标签: php html soap

我正试图从我的中央银行获得货币汇率并插入数据库中的表格。 我的PHP脚本如下:

    <?php 
$DB_HOST = "localhost:3306";
$DB_USER = "********";
$DB_PASS = "********";
$DB_NAME = "********";

$db = mysql_connect($DB_HOST,$DB_USER,$DB_PASS) or die("No Connection ".mysql_error());
mysql_select_db($DB_NAME,$db) or  die("Error In database");

function qry($action,$sql,$type='s'){
    $sql = mysql_query($sql) or die(mysql_error());
    if($action=='select'){
            $num = mysql_num_rows($sql);
        if($num>0){
            if($type=='m'){
                while($row = mysql_fetch_object($sql)){
                    $result[] = $row;
                }
            }else{
                    $result = mysql_fetch_object($sql);
            }
        }else{
            $result = 0;
        }
    }else{
        $result = $sql;
    }
    return $result;
}

/**Code for getting Rubel to USd Exchange rate against central bank of russia **/
$url = "http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL";
$client = new SoapClient($url);
$fcs = $client->__getFunctions();
//var_dump($fcs);
if (!isset($date)) {
     $date = date("Y-m-d");
}
$curs = $client->GetCursOnDate(array("On_date" => $date));
$ratesXml = new SimpleXMLElement($curs->GetCursOnDateResult->any);
foreach($ratesXml->ValuteData->ValuteCursOnDate as $ValuteCursOnDate){
    //print_r($ValuteCursOnDate);
    if(strtolower($ValuteCursOnDate->VchCode) == 'usd'){
        $ramt = $ValuteCursOnDate->Vcurs;
    }
}

if(isset($_REQUEST['job']) && !empty($_REQUEST['job'])) {
    if($_REQUEST['job'] == 'Xey6ka6_ASAqaj') {
        $sql = "INSERT INTO `manage_exchange_rate` (`ex_id`, `from`, `to`, `amount`, `created`) VALUES (NULL, 'RUB', 'USD', '".$ramt."', CURRENT_TIMESTAMP)";
    echo $sql;
        mysql_query($sql);
        print '
        job: ['.$_REQUEST['job'].']
        ex_id:['.mysql_insert_id().']
        from:[RUB]
        to:[USD]
        amount:['.$ramt.']
        ';
    }
}


?>

但是,当我使用我的脚本作为cron作业时,我遇到以下错误。

  

PHP致命错误:/ var / www / vhosts / MY中找不到类'SoapClient'   第33行的DOMAIN / httpdocs / Admin / cron_money_exchange.php

请帮我找错时。提前谢谢。

0 个答案:

没有答案