July 18, 201412 yr I have been trying to make a user control panel and I have no idea why I keep getting MySQL Syntax errors. Here is the error: Here is my database structure: And here is my code for private.php: http://pastebin.com/GL2eW6Jp I'm trying to set scrim to 1 or 0. Thanks in advance, Advisor Edited July 18, 201412 yr by Advisor
July 18, 201412 yr Looking at the error the syntax is wrong on the "ID =" as the first symbol after the equals sign is a single quote then the one after the number is a double quote. This suggests that the code you are using is applying two different symbols rather than the same one causing the error
July 18, 201412 yr Looking at the error the syntax is wrong on the "ID =" as the first symbol after the equals sign is a single quote then the one after the number is a double quote. This suggests that the code you are using is applying two different symbols rather than the same one causing the error No he is using single quotes correctly (PDO is inserting these) what looks like a double quote is actult two single quotes 'WHERE id = '6'' mysql throws the error within single quotes (and is rather annoying) What the OP can do is put the column names within single quotes or backticks (`) as sometimes the colum names can break a query Edited July 18, 201412 yr by D4Y0
July 18, 201412 yr Author @@D4Y0 I hope this is what you wanted: UPDATE lfs SET email = :email , scrim = :scrim , password = :password , salt = :salt , WHERE id = :user_id ;
July 18, 201412 yr Possibly an extra comma that's not needed, after salt. Edit, yeah just remove the comma after salt = :salt, as the query is expecting another value. if($password !== null) { $query .= " password = :password , salt = :salt "; } Also, why not use a BOOLEAN data type for SCRIM in the DB rather than INT, if it's only ever going to be a 1 or a 0? Edited July 18, 201412 yr by Lyndsey
July 18, 201412 yr Author @@Lyndsey That doesn't have seemed to work either. It just replies with the same error.
Create an account or sign in to comment