truegilly Posted December 8, 2006 Share Posted December 8, 2006 Hi I have a simple database that I am allowing a user to delete a row from.[color=red]Here is my Query.. define("QUERY", "DELETE FROM Artefact WHERE dbArtefactId = ? AND dbEmployeeId = ?;");[/color]To validate the data the user enters for both dbArtefactId and dbEmployeeId I have added a switch statement that uses the mysqli_affected_rows function that calls the variable $statement.$statement is assigned... [color=red]$statement = mysqli_prepare($connection, QUERY);[/color]Here is the switch statement….[color=red]switch(mysqli_affected_rows($statement)) { case 1: // success one row affected $useCaseComplete = true; $useCaseOutcomeMessage = $_POST['frmfileId'] . " File Deleted"; break; case 0: // Fail 0 rows affected $invalidOwnerIdMessage = "No artifact found."; break; default: // something else failed - just give up $useCaseComplete = true; $useCaseOutcomeMessage = mysqli_stmt_errno($statement); break; }[/color]I assume that when a row has been deleted it return “1 row affected”, but when the user enters garbage data it reply’s “0 rows affected”When I test the page it gives me the following error.....Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, object given in H:\p3t\public_php on line 70Anyone have any ideas ??thanks Truegilly Quote Link to comment Share on other sites More sharing options...
truegilly Posted December 8, 2006 Author Share Posted December 8, 2006 ok i found (by total chance) that if i type mysqli_stmt_affected_rowsit works.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.