Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $regex = '/.*bKd{4}-d{2}-d{2}/s';
- preg_match_all($regex, $entry_raw, $date, PREG_SET_ORDER, 0);
- $date = $date[0][0];
- // TRIM 'BODY' DOWN TO FIRST PARAGRAPH
- $entry = explode("n", $entry_raw);
- // CONNECT TO DATABASE
- $hostname = "xxx";
- $database = "xxx";
- $username = "xxx";
- $password = "xxx";
- $con = mysqli_connect($hostname, $username, $password, $database) or die (mysql_error());
- if ($con->connect_error) {
- die("ERROR: Unable to connect: " . $con->connect_error);
- }
- $stmt = $con->prepare("SELECT id FROM users WHERE email=?");
- $stmt->bind_param("s", $from[1]);
- $stmt->execute();
- $stmt->bind_result($id);
- $stmt->fetch();
- $stmt->close();
- if ($id) {
- $stmt = $con->prepare("INSERT INTO entries (entry, user_id, date) VALUES (?, ?, ?)");
- $stmt->bind_param("sis", $entry[0], $id, $date);
- $stmt->execute();
- $stmt->close();
- }
- $entry_raw = "this is some text 1111-11-11 2222-22-22 this is some more text";
- $regex = '/.*bKd{4}-d{2}-d{2}/s';
- preg_match_all($regex, $entry_raw, $date, PREG_SET_ORDER, 0);
- $date = $date[0][0];
- echo $date;
Add Comment
Please, Sign In to add comment