0

So i'm making this project, and one of the INSERT queries I'm using seems to malfunction. I have other INSERT queries on the same project that do work, so I'm not really sure what the problem is. This is the query that malfunctions. Dumping the errors turns up nothing, but no rows are affected.

$qry3 = $conn->prepare("INSERT INTO usermovie(user,movie) VALUES(:user, :filmid)");
$qry3->bindParam(':user',$user,PDO::PARAM_STR,16);
$qry3->bindParam(':filmid',$film,PDO::PARAM_INT);
$qry3->execute();                    //usermovie, user and movie are the correct names for the table and columns.

For comparison, this insert query in the same project does work, and creates a new entry.

$qry2 = $conn->prepare("INSERT INTO users(userid,userpass,email,credits) VALUES(:username, :password, :email,0)");
$qry2->bindParam(':username', $nusername, PDO::PARAM_STR, 16);
$qry2->bindParam(':password', $npassword, PDO::PARAM_STR, 16);
$qry2->bindParam(':email', $nemail, PDO::PARAM_STR, 16);
$qry2->execute();

EDIT: It seems the solution didn't have anything to do with this, the server updated the script wrong and was using an old malfunctioning version, so this wasn't the problem. I guess this question can be deleted.

Ghijs Kilani
  • 166
  • 1
  • 9
  • 1
    possible duplicate of [How to squeeze error message out of PDO?](http://stackoverflow.com/questions/3726505/how-to-squeeze-error-message-out-of-pdo) – Pekka Aug 25 '13 at 18:03

1 Answers1

1

Add the following to the top of your PHP script so that you can see all PHP error messages:

error_reporting(E_ALL);
ini_set('display_errors', '1');

You could also check the return, or error, values from some of your database methods.

In some databases user is a reserved keyword and needs to be surrounded in back-ticks or square-brackets, depending on the database.

Andy G
  • 19,232
  • 5
  • 47
  • 69