elis Posted May 22, 2009 Share Posted May 22, 2009 I keep receiving the following error: " Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry" but can't figure out why. I've gone through the code a few times, but haven't spotted it. Perhaps a second pair of eyes would help? <? $qry = "CALL CandidatesNewVerMay(:fname, :lname, :writeup, :resume_text, :notes, :resume_doc, :resume_filetype, :resume_filename, :add_doc, :add_filetype, :add_filename, :recruiter_id, :email, :phone, :address, :source_id, :clarity, :personability, :year_began, :i9, :i9notes, :salary, :company, :base, :bonus, :year, :salnotes, :desiredbase, :desiredbonus, :desirednotes)"; $stmt = $conn->prepare($qry); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt->bindParam(':fname', $fname, PDO::PARAM_STR); $stmt->bindParam(':lname', $lname, PDO::PARAM_STR); $stmt->bindParam(':writeup', $writeup, PDO::PARAM_STR); $stmt->bindParam(':resume_text', $resume_text, PDO::PARAM_STR); $stmt->bindParam(':notes', $notes, PDO::PARAM_STR); $stmt->bindParam(':resume_doc', $resume_doc, PDO::PARAM_LOB); $stmt->bindParam(':resume_filetype',$resume_filetype, PDO::PARAM_STR); $stmt->bindParam(':resume_filename',$resume_filename, PDO::PARAM_STR); $stmt->bindParam(':add_doc', $add_doc, PDO::PARAM_LOB); $stmt->bindParam(':add_filetype', $add_filetype, PDO::PARAM_STR); $stmt->bindParam(':add_filename', $add_filename, PDO::PARAM_STR); $stmt->bindParam(':recruiter_id', $recruiter_id, PDO::PARAM_INT); $stmt->bindParam(':email', $email, PDO::PARAM_STR); $stmt->bindParam(':phone', $phone, PDO::PARAM_STR); $stmt->bindParam(':address', $address, PDO::PARAM_STR); $stmt->bindParam(':source_id', $source_id, PDO::PARAM_INT); $stmt->bindParam(':clarity', $clarity); $stmt->bindParam(':personability', $personability); $stmt->bindParam(':year_began', $year_began, PDO::PARAM_INT); //new addons $stmt->bindParam(':i9', $i9, PDO::PARAM_STR); $stmt->bindParam(':i9notes', $i9notes, PDO::PARAM_STR); $stmt->bindParam(':salary', $salary, PDO::PARAM_STR); $stmt->bindParam(':company', $company, PDO::PARAM_STR); $stmt->bindParam(':base', $base, PDO::PARAM_STR); $stmt->bindParam(':bonus', $bonus, PDO::PARAM_STR); $stmt->bindParam(':year', $year, PDO::PARAM_STR); $stmt->bindParam(':salnotes', $salnotes, PDO::PARAM_STR); $stmt->bindParam(':desiredbase', $desiredbase, PDO::PARAM_STR); $stmt->bindParam(':desiredbonus', $desiredbonus, PDO::PARAM_STR); $stmt->bindParam(':desirednotes', $desirednotes, PDO::PARAM_STR); $stmt->execute();?> And here is what "CandidatesNewVerMay" is: CREATE DEFINER=`itwallstreet`@`%` PROCEDURE `CandidatesNewVerMay`( IN _fname VARCHAR(30), IN _lname VARCHAR(30), IN _writeup TEXT, IN _resume_text TEXT, IN _notes TEXT, IN _resume_doc MEDIUMBLOB, IN _resume_filetype VARCHAR(30), IN _resume_filename VARCHAR(60), IN _add_doc MEDIUMBLOB, IN _add_filetype VARCHAR(30), IN _add_filename VARCHAR(60), IN _recruiter_id INT, IN _email VARCHAR(80), IN _phone VARCHAR(30), IN _address VARCHAR(200), IN _source_id INT, IN _clarity INT, IN _personability INT, IN _year_began INT, IN _i9 VARCHAR(45), IN _i9notes TEXT, IN _salary VARCHAR(25), IN _company VARCHAR(45), IN _base VARCHAR(25), IN _bonus VARCHAR(25), IN _year VARCHAR(4), IN _salnotes TEXT, IN _desiredbase VARCHAR(10), IN _desiredbonus VARCHAR(10), IN _desirednotes TEXT) BEGIN DECLARE lid INT; INSERT INTO candidates_info (fname, lname, recruiter_id, date_created, email, phone, address, source_id, clarity, personability, year_began, i9, i9notes) VALUES (_fname, _lname, _recruiter_id, NOW(), _email, _phone, _address, _source_id, _clarity, _personability, _year_began, _i9, _i9notes); SELECT LAST_INSERT_ID() INTO lid; INSERT INTO candidates_data (candidate_id, writeup, notes, resume_text) VALUES (lid, _writeup, _notes, _resume_text); INSERT INTO candidates_salary (candidates_id, salary, company, base, bonus, year, notes, desiredbonus, desiredbase, desirednotes) VALUES (lid, _salary, _company, _base, _bonus, _year, _salnotes, _desiredbonus, _desiredbase, _desirednotes); IF _add_doc IS NOT NULL THEN INSERT INTO candidateResumes (candidate_id, resume_doc, resume_filetype, resume_filename) VALUES (lid, _add_doc, _add_filetype, _add_filename); END IF; IF _resume_doc IS NOT NULL THEN INSERT INTO candidateResumes (candidate_id, resume_doc, resume_filetype, resume_filename) VALUES (lid, _resume_doc, _resume_filetype, _resume_filename); END IF; SELECT lid; END All of the variables are simple POSTs but because I have so many of them, I thought it might help to exclude them. But if anyone thinks it might help to see them, please let me know. Link to comment https://forums.phpfreaks.com/topic/159261-solved-receiving-an-error-in-pdo-cant-locate-the-problem/ Share on other sites More sharing options...
radi8 Posted May 22, 2009 Share Posted May 22, 2009 This appears to mean that there is already an entry in the table that matches the one you are creating. Ensure that you are not duplicating a record's primary index. Link to comment https://forums.phpfreaks.com/topic/159261-solved-receiving-an-error-in-pdo-cant-locate-the-problem/#findComment-839955 Share on other sites More sharing options...
elis Posted May 22, 2009 Author Share Posted May 22, 2009 Thanks, you pointed me in the right direction. I needed to change the id field from tinyint to int. Link to comment https://forums.phpfreaks.com/topic/159261-solved-receiving-an-error-in-pdo-cant-locate-the-problem/#findComment-839966 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.