Forum Moderators: coopster

Message Too Old, No Replies

Insert info into one database and delete from another.

         

swelch15

12:46 am on Jun 14, 2018 (gmt 0)

5+ Year Member



I am trying to simultaneously insert information into one table and then delete information from another. The information is being copied into the one table successfully but it is not deleting it from the other table.
Thanks in advance:

<?php include('../../connect.php'); ?>

<?php
$UniqueID = mysqli_real_escape_string($dbc, $_POST['UniqueID']);
$DateDeleted = mysqli_real_escape_string($dbc, $_POST['DateDeleted']);
$FirstName = mysqli_real_escape_string($dbc, $_POST['FirstName']);
$LastName = mysqli_real_escape_string($dbc, $_POST['LastName']);
$Team = mysqli_real_escape_string($dbc, $_POST['Team']);
$Email = mysqli_real_escape_string($dbc, $_POST['Email']);
$Gender = mysqli_real_escape_string($dbc, $_POST['Gender']);
$Country = mysqli_real_escape_string($dbc, $_POST['Country']);
$Division = mysqli_real_escape_string($dbc, $_POST['Division']);
$TeamID = mysqli_real_escape_string($dbc, $_POST['TeamID']);
$Reason = mysqli_real_escape_string($dbc, $_POST['Reason']);
$OtherContactInfo = mysqli_real_escape_string($dbc, $_POST['OtherContactInfo']);



//$result = mysqli_query($dbc, "INSERT INTO `Teams`(`Team`, `TeamFirstName`, `TeamLastName`, `TeamFullName`, `AlternateEmails`, `ContactType`, `Division`, `EditedBY`, `FacebookCode`, `FBID`, `JobTitle`, `LastUpdated`, `Notes`, `RegistrationDate`, `TeamCity`, `TeamCountry`, `TeamEmail`, `TeamGender`, `TeamID`, `TeamMobile`, `TeamPhone`, `TeamStreetAddress`) VALUES ('$Team','$TeamFirstName','$TeamLastName','$TeamFullName','$AlternateEmails','$ContactType',$Division,'$EditedBY','$FacebookCode','$FBID','$JobTitle','$LastUpdated','$Notes','$RegistrationDate','$TeamCity','$TeamCountry','$TeamEmail','$TeamGender','$TeamID','$TeamMobile','$TeamPhone','$TeamStreetAddress')");


$result = mysqli_query($dbc, "INSERT INTO DeletedContacts (UniqueID,DateDeleted,FirstName,LastName,Team,Email,Gender,Country,Division,TeamID,Reason,OtherContactInfo) VALUES ('$UniqueID', '$DateDeleted', '$FirstName', '$LastName', '$Team', '$Email', '$Gender', '$Country', '$Division', '$TeamID', '$Reason', '$OtherContactInfo')");

// -- having spaces between my variables screwed everything up. Do not put quotes around the numeric values

$Remove = mysqli_query($dbc, "DELETE FROM Teams WHERE UniqueID = $UniqueID");


?>

<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">

</head>
<body>

<br>The Following information has been deleted from the database:
<br>Team: <?php echo $Team; ?>
<br>First Name: <?php echo $FirstName; ?>

</body>
<html>


QuaterPan

8:50 am on Jun 14, 2018 (gmt 0)



From what I understand, here, you are doing tow insertions. No deletion. Or may be you meant the second insertion, (which seems to be a db to store deleted data) is not working?

swelch15

3:03 pm on Jun 14, 2018 (gmt 0)

5+ Year Member



I actually figured it out. The problem was that one of the variables was not being sent by the form.

tangor

7:46 am on Jun 15, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Happy result. Most times it is something overlooked, and with code that is often possible! That's one reason I still use graph paper, pencil, and leaving it for 24-48 hours and coming back to look again.

All too often we see what we want to see, not what we actually coded. Been there, done that, will probably do it again and again and again...