So here is it, I have been bashing my head over this and I don't know why I can not figure this out. I keep getting the following error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''menu' WHERE id = '120'' at line 1

:::: BELOW IS THE CODE THAT I AM HAVING AN ISSUE WITH ::::::

<?php
session_start();
if (!isset($SESSION["manager"])) {
header("location: admin_login.php");
exit();
}
// Be sure to check that this manager SESSION value is in fact in the database
$managerID = preg_replace('#[0-9]#i', '', $
SESSION["id"]);
$manager = preg_replace('#[A-Za-z0-9]#i', '', $SESSION["manager"]);
$password = preg_replace('#[A-Za-z0-9]#i', '', $
SESSION["password"]);

// Connect to the MySQL database

include "../../includes/connect.php";
$sql = mysql_query("SELECT * FROM users WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");

// ------- MAKE SURE PERSON EXISTS IN DATABASE ---------
$existCount = mysql_num_rows($sql); // count the row nums
if ($existCount == 0) { // evaluate the count
echo "Your login information is not in our database.";
exit();
}
?>
<?php
$pageType = $GET['type'];
$pageID = $
GET['id'];

$sql2 = mysql_query("DELETE FROM '$pageType' WHERE id = '$pageID'") or die(mysql_error());
echo "User has been deleted";

header("location: list.php?type=$pageType");

?>

If someone can please help me, I would be so grateful!

PP

    Use "back ticks" to quote identifiers (versus straight quotes for string literals):

    $sql2 = mysql_query("DELETE FROM `$pageType` WHERE id = '$pageID'") or die(mysql_error());
    

      Thank you for that, I knew it was something small!

        Write a Reply...