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
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.

Link to comment
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.

 

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.