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


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.