Guest User

Untitled

a guest
Jan 25th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. $regex = '/.*bKd{4}-d{2}-d{2}/s';
  2. preg_match_all($regex, $entry_raw, $date, PREG_SET_ORDER, 0);
  3.  
  4. $date = $date[0][0];
  5.  
  6. // TRIM 'BODY' DOWN TO FIRST PARAGRAPH
  7. $entry = explode("n", $entry_raw);
  8.  
  9. // CONNECT TO DATABASE
  10. $hostname = "xxx";
  11. $database = "xxx";
  12. $username = "xxx";
  13. $password = "xxx";
  14.  
  15. $con = mysqli_connect($hostname, $username, $password, $database) or die (mysql_error());
  16.  
  17. if ($con->connect_error) {
  18. die("ERROR: Unable to connect: " . $con->connect_error);
  19. }
  20.  
  21. $stmt = $con->prepare("SELECT id FROM users WHERE email=?");
  22. $stmt->bind_param("s", $from[1]);
  23. $stmt->execute();
  24. $stmt->bind_result($id);
  25. $stmt->fetch();
  26. $stmt->close();
  27.  
  28. if ($id) {
  29. $stmt = $con->prepare("INSERT INTO entries (entry, user_id, date) VALUES (?, ?, ?)");
  30. $stmt->bind_param("sis", $entry[0], $id, $date);
  31. $stmt->execute();
  32. $stmt->close();
  33. }
  34.  
  35. $entry_raw = "this is some text 1111-11-11 2222-22-22 this is some more text";
  36. $regex = '/.*bKd{4}-d{2}-d{2}/s';
  37. preg_match_all($regex, $entry_raw, $date, PREG_SET_ORDER, 0);
  38. $date = $date[0][0];
  39. echo $date;
Add Comment
Please, Sign In to add comment