Jump to content

mysqli_affected_rows() expects parameter 1 to be mysqli... PLEASE HELP !!


truegilly

Recommended Posts

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 70

Anyone have any ideas ??

thanks

Truegilly


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.