I need to insert a row into a database using PDO. But it doesn't work and it doesn't print any errors so I don't know where the problem can be.
The connection is okay, because I can run UPDATE queries.
But on this query it gets stuck without printing any error:
$dbtype = "mysql";
$dbhost = "xxx";
$dbname = "xxx";
$dbuser = "xxx";
$dbpass = "xxx";
$db = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "INSERT INTO users (id, name) VALUES (:id,:name)";
$q = $db->prepare($sql);
$q->execute(array(
':id'=>$id,
':name'=>$name
));
Is there any other way to debug except this command?
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);