daily pastebin goal
68%
SHARE
TWEET

Untitled

a guest Apr 27th, 2018 245 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     $dsn = xxx;
  3.     $user = xxx;
  4.     $password = xxx;
  5.     $dbh = new PDO($dsn, $user, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
  6.  
  7.     $date = date("d/m/Y"); // Текущая дата
  8.     $content = simplexml_load_file("https://www.cbr.ru/scripts/XML_daily.asp?date_req=".$date);
  9.    
  10.     $eur = $content->xpath('Valute[@ID="R01239"]')[0]->Value;
  11.     $euro= ceil($eur + $eur*2.5/100);
  12.    
  13.     try{
  14.             $res = $dbh->query("UPDATE `booking_val` SET `rate` = ".$euro." WHERE `id` = 1 ");
  15.             $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16.     }
  17.     catch (Exception $e) {
  18.         echo 'Подключение не удалось: ' . $e->getMessage();    
  19.     }
  20.  
  21. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top