daily pastebin goal
31%
SHARE
TWEET

Untitled

a guest Jun 29th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3.   $dbHost = 'localhost';
  4.   $dbName = 'invento';
  5.   $dbUser = 'root';
  6.   $dbPass = '';
  7.  
  8. try {
  9.  
  10.   $pdo = new PDO("mysql:host=$dbHost;dbname=$dbName","$dbUser", "$dbPass");
  11.   $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.  
  13. } catch(Exception $e) {
  14.  
  15.   echo $e->getMessage();
  16. }
  17.  
  18.  
  19. $html = file_get_contents('https://www.google.com');
  20. preg_match('/<title>(.*)</title>/i', $html, $title);
  21.  
  22. $title_out = $title[1];
  23.  
  24. $sql = "INSERT INTO prueba (title) VALUES ($title_out)";
  25.  
  26.   $query = $pdo->prepare($sql);
  27.  
  28.   $result = $query->execute([
  29.     'title' => $title_out
  30.   ]);
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