Jump to content

[SOLVED] Receiving an error in PDO, can't locate the problem


elis

Recommended Posts

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.