简体   繁体   中英

PHP PDO INSERT query failing

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM