Battleroid
Battleroid

Reputation: 881

Cannot insert with PHP and PDO

After migrating to PDO from a previous question, I've hit a small snag. I can't insert information into a MySQL table.

Here's what I have:

include_once(db.php);

$platform = $_POST['platform'];
$location = $_POST['location'];
$name = $_POST['name'];
$secret = sha1($_POST['password']);

$sql = $db->prepare("INSERT INTO `servers` (`id`, `secret`, `platform`, `location`, `name`) VALUES (:id, :secret, :platform, :location, :name)");
$sql->bindValue(':id', 'null');
$sql->bindValue(':secret', $secret);
$sql->bindValue(':platform', $platform);
$sql->bindValue(':location', $location);
$sql->bindValue(':name', $name);
$sql->execute();

I can't find a reason why it won't insert new records.

Upvotes: 0

Views: 84

Answers (1)

Battleroid
Battleroid

Reputation: 881

I durr'd hard.

include_once(db.php); needed quotes: include_once("db.php");

I feel like a gigantic moron for wasting 2 hours on why inserting wouldn't work.

Upvotes: 2

Related Questions