doubledee Posted December 25, 2011 Share Posted December 25, 2011 How can I make my INSERT query *fail* so that I can test this code... // Verify Insert. if (mysqli_stmt_affected_rows($stmt)==1){ // Insert Succeeded. // Set Message. $_SESSION['resultsCode'] = 'ACCOUNT_MEMBER_ACCT_CREATED'; $_SESSION['registrationEmail'] = $email; }else{ // Insert Failed. $_SESSION['resultsCode'] = 'ACCOUNT_MEMBER_ACCT_FAILED'; }// End of VERIFY INSERT. Thanks, Debbie Link to comment https://forums.phpfreaks.com/topic/253812-how-create-failed-insert/ Share on other sites More sharing options...
premiso Posted December 25, 2011 Share Posted December 25, 2011 It depends on how you want it to fail. There is the SQL SYNTAX, which you could just change INSERT to something different. Or there is a violation of some type of restraint, such as a duplicate id on a primary key field, a non-unique item on a unique field etc. With what you have given, it is impossible for us to guide you without knowing how you want to fail and seeing the relevant sql structure / code. Link to comment https://forums.phpfreaks.com/topic/253812-how-create-failed-insert/#findComment-1301240 Share on other sites More sharing options...
doubledee Posted December 25, 2011 Author Share Posted December 25, 2011 It depends on how you want it to fail. There is the SQL SYNTAX, which you could just change INSERT to something different. Or there is a violation of some type of restraint, such as a duplicate id on a primary key field, a non-unique item on a unique field etc. With what you have given, it is impossible for us to guide you without knowing how you want to fail and seeing the relevant sql structure / code. I want the IF-THEN-ELSE above to fail on an INSERT. What additional code do you need to see? I just have a standard INSERT query in a standard Prepared Statement, so I thought what I provided was enough?! Debbie Link to comment https://forums.phpfreaks.com/topic/253812-how-create-failed-insert/#findComment-1301263 Share on other sites More sharing options...
The Little Guy Posted December 26, 2011 Share Posted December 26, 2011 add an extra quote at the end of the query. Link to comment https://forums.phpfreaks.com/topic/253812-how-create-failed-insert/#findComment-1301402 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.