Jump to content

Commands out of sync; you can't run this command now


Danny620

Recommended Posts

Commands out of sync; you can't run this command now

Query: DELETE FROM case_ref WHERE user_id='3';DELETE FROM updates WHERE user_id='3'

 

 

php]<?php

 

// Check if the form has been submitted:

if (isset($_POST['delete'])) {

 

if ($_POST['sure'] == 'Yes') { // Delete the record.

 

// Make the query:

$query =  "DELETE FROM case_ref WHERE user_id='$id';";

$query .=  "DELETE FROM updates WHERE user_id='$id'";

$r = mysqli_multi_query ($dbc, $query);

 

if (mysqli_affected_rows($dbc) >= 1) { // If it ran OK.

 

echo '<h3>All cases & updates associated with user have been deleted</h3>';

 

}

 

// Make the query:

$q = "DELETE FROM users WHERE user_id='$id' LIMIT 1";

$r = $r = mysqli_query ($dbc, $q);

 

if (mysqli_affected_rows($dbc) == 1) { // If it ran OK.

 

echo '<h3>User has been deleted</h3>';

 

} else { // If the query did not run OK.

$errors[] = '<p class="error">The user could not be deleted due to a system error.</p>'; // Public message.

$errors[] = '<p>' . mysqli_error($dbc) . '<br />Query: ' . $query . '</p>'; // Debugging message.

}

 

 

} else { // No confirmation of deletion.

$errors[] = '<p class="error">The user has NOT been deleted.</p>';

}

 

}else{ //show the form

 

echo '<form id="form1" name="form1" method="post" action="delete_user.php?user_id=' . $id . '">

<table width="100%" border="1" cellpadding="5" cellspacing="5">

  <tr>

    <td width="30%">Do you wish to delete this user?</td>

    <td width="19%"><input type="radio" name="sure" value="Yes" />

    Yes </td>

    <td width="17%"><input type="radio" name="sure" value="No" checked="checked" />

    No</td>

    <td width="34%">

      <input type="submit" name="button" id="button" value="Submit" />

      <input name="delete" type="hidden" id="delete" value="1" /></td>

  </tr>

</table>';

 

}

 

// Print any error messages, if they exist:

if (!empty($errors)) {

foreach ($errors as $msg) {

echo "$msg\n";

}

}

 

mysqli_close($dbc);

 

?>[/code]

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.