Advertisement
Guest User

Untitled

a guest
Nov 28th, 2017
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1.  
  2. <?php
  3.     $host = '127.0.0.1';
  4.     $port = 3306;
  5.     $user = 'root';
  6.     $pass = 'root';
  7.     $name = 'mydb';
  8.  
  9.     try {
  10.         $conn = new PDO("mysql:host=$host;port=$port;dbname=$name", $user, $pass);
  11.         $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  12.  
  13.         echo "DB: Connected successfully\n";
  14.  
  15.        
  16.  
  17.  
  18.        {
  19.             $file = escapeshellarg('/var/www/results_m.csv');
  20.             $last_line = `tail -n 1 $file`;
  21.             echo $last_line;
  22.             $sql = $conn->prepare("INSERT INTO dust1 VALUES (?, ?, ?, ?, ?, ?)");
  23.             $sql->execute($last_line);
  24.      
  25.         echo 'DONE';
  26.     } catch(PDOException $e) {
  27.         echo "DB: Connection failed: ".$e->getMessage();
  28.     } catch(Exception $e) {
  29.         echo 'ERROR: '.$e->getMessage();
  30.     }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement