daily pastebin goal
49%
SHARE
TWEET

Untitled

a guest Jun 30th, 2018 67 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.   ]);
  31.    
  32. $title_out = $title[1];
  33. $sql = "INSERT INTO prueba (title) VALUES (:title)";
  34. $query = $pdo->prepare($sql);
  35. $result = $query->execute(['title' => $title_out]);
  36.    
  37. $title_out = $title[1];
  38. $sql = "INSERT INTO prueba (title) VALUES (?)";
  39. $query = $pdo->prepare($sql);
  40. $result = $query->execute([$title_out]);
  41.    
  42. $html = file_get_contents('https://www.google.com');
  43. $dom = new domdocument();
  44. $dom->loadHTML($html);
  45. $titleout = $dom->getElementsByTagName('title')[0]->nodeValue;
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