A
Anonymous
Guest
Hello.
I have 2 tables that store the same information for different groups. When I run this for the "pilots", the query executes successfully and the record is changed. However, when the "data" variable is mentors, the query executes and throws no errors, but does not change the cells information.
In the query if, you can see all the debugging I have attempted. Both data values outpout correctly, all the values are matching what they should, but the mentor table does not update.
Any ideas are much appreciated.
Thank you!
(Page output)
good
UPDATE mentors SET status='Account Created' WHERE id='6'
mentors
Account Created
6
I have 2 tables that store the same information for different groups. When I run this for the "pilots", the query executes successfully and the record is changed. However, when the "data" variable is mentors, the query executes and throws no errors, but does not change the cells information.
In the query if, you can see all the debugging I have attempted. Both data values outpout correctly, all the values are matching what they should, but the mentor table does not update.
Any ideas are much appreciated.
Thank you!
Code:
<?php
$id = $_GET['id'];
$status = $_GET['status'];
$database = $_GET['data'];
switch ($database) {
case 'ip':
$database = "pilots";
break;
case 'im':
$database = "mentors";
break;
default:
echo "Invalid";
exit();
}
switch ($status)
{
case 's1':
$status = "Email Sent";
break;
case 's2':
$status = "Account Created";
break;
case 's3':
$status = "Contacted";
break;
case 's4':
$status = "Ready to Pair";
break;
case 's5':
$status = "Active-Paired";
break;
case 's6':
$status = "Inactive";
break;
default:
$status = "FALSE";
echo 'Invalid';
exit();
}
if (isset($status) && $status != "FALSE")
{
// Create connection
$conn = mysqli_connect("localhost", "root", "", "interestedpilots");
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "UPDATE $database SET status='$status' WHERE id='$id'";
if (mysqli_query($conn, $sql)) {
$result = mysqli_query($conn, $sql);
/*header("Location: interestedPilots.php");*/
echo $result ? 'good' : 'failed with ' . mysqli_error($connection);
echo '<br>';
echo $sql;
echo '<br>';
echo $database;
echo '<br>';
echo $status;
echo '<br>';
echo $id;
} else {
echo "Error updating record: " . mysqli_error($conn);
}
mysqli_close($conn);
}
?>
good
UPDATE mentors SET status='Account Created' WHERE id='6'
mentors
Account Created
6