I'm completely stumped with this one.
I'm using PDO to insert a record into a generic 'users' table and when attempting to insert one record, two identical records are being inserted. It's as if the insert statement is running twice. As an added note, this code is being run on a vagrant machine (scotchbox/pro). The vagrant machine is serving correctly and the code shown below is the first thing in my index file, so no other code is affecting it.
index.php:
<?php
$host = 'localhost';
$user = 'root';
$password = 'root';
$dbname = 'home';
$dsn = 'mysql:host=' . $host . ';dbname=' . $dbname;
$pdo = new PDO($dsn, $user, $password);
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$admin = 0;
$name = 'Frank';
$sql = 'INSERT INTO users(name, admin) VALUES (:name, :admin)';
$statement = $pdo->prepare($sql);
$statement->execute(['name' => $name, 'admin' => $admin]);
die();
.htaccess:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
I've tried removing specific lines that could be affecting it such as the setAttribute line but to no avail. Any help would be amazing! Thanks in advance.