0

Good God, I've been stuck for like 2 hours, I suppose I can't think clearly anymore, but I just don't see why the statement below won't work, please help me out :

<?php session_start();
	$username = $_GET['username'];

	$db = new PDO('mysql:host=localhost;dbname=subscribers', 'root', '');
	$sql = "INSERTO INTO users (username) VALUES (?)";
	$stmt = $db->prepare($sql);
	$stmt->execute(array($username));
?>

There are no errors after the query is ran, however the value is not inserted, nothing happens!

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by hermann87
0

Try to execute the query manually in mysql. It may be unique field index, wrong field name that's preventing inserting new value.

0

Yes.. Try to debug printed sql query in phpmyadmin.

echo $sql = "INSERTO INTO users (username) VALUES (?)"; exit;
0

Just noticed the typo INSERTO should be INSERT.

That was it! I think I would have never noticed!
Thank you!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.