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!

Recommended Answers

All 4 Replies

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

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

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

Just noticed the typo INSERTO should be INSERT.

Just noticed the typo INSERTO should be INSERT.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.