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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Hmm, it seems my main page was calling the wrong php-script. I fixed that and the original one is working now. Thanks anyway!
He, he! Not much I could do about that :). Glad you sorted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.