Jump to content

How create Failed INSERT?


doubledee

Recommended Posts

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

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.

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

 

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.