0

There is a parser script in curl, as well as a script that creates a database and writes sparse data to this database. How to make sure that each time the script is run, the sparse data is not written to the new table, but updated instead of the old data? I know that there is an UPDATE function. But I do not understand how to apply it. Here is an example script:

<?php $___notjson=1; ini_set('display_errors', 1); header ('Content-type: text/html; charset=utf-8'); require ('phpQuery.php'); $ch = curl_init('http://allhyipdata.com/hyip/bitcy.biz'); curl_setopt($ch, CURLOPT_USERAGENT, "booyah!"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $allhyipdata = curl_exec($ch); curl_close($ch); $doc = phpQuery::newDocument($allhyipdata); $ssl = $doc->find('.no-padding-bottom tr:eq(1) td:eq(3)')->text(); $ddos = $doc->find('.no-padding-bottom tr:eq(2) td:eq(3)')->text(); echo '<div>SSL:' .$ssl .'</div>'; echo '<div>DDoS:' .$ddos .'</div>'; try { $db = new PDO('sqlite:bitcy.biz'); $db->exec("CREATE TABLE IF NOT EXISTS `bitcy.biz` ( `ssl` VARCHAR, `ddos` VARCHAR ); "); } catch ( PDOException $e ) { exit("Ошибка: ".$e->getMessage()."<br>Строка: ".$e->getLine()); } $db->query("INSERT INTO `bitcy.biz` (ssl, ddos) VALUES ('$ssl', '$ddos')"); $result = $db->query('SELECT * FROM `bitcy.biz`')->fetchAll(PDO::FETCH_ASSOC); print_r($result); // Array ( [0] => Array ( [ssl]=> $ssl [ddos]=> $ddos ) ) ?> 
5
  • 1
    English please, if possible! Commented Nov 18, 2017 at 7:55
  • 1
    Your site is ru.stackoverflow.com Commented Nov 18, 2017 at 7:59
  • Hello. There is a parser script in curl, as well as a script that creates a database and writes sparse data to this database. How to make sure that each time the script is run, the sparse data is not written to the new table, but updated instead of the old data? I know that there is an UPDATE function. But I do not understand how to apply it. Here is an example script: Commented Nov 18, 2017 at 7:59
  • Please, do not write comments, edit your question. Commented Nov 18, 2017 at 8:00
  • Thank you for your help, I found something for myself. And you can make it so that the UPDATE function is executed once every 24 hours. Ie, if you sent a request to add or change an entry in the database file, the next update of the database can be done only tomorrow, after 24 hours for example. I ask you to apologize for the level of my English, all translation is carried out through Google translator Commented Nov 18, 2017 at 10:19

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.