Im having problem writing my cms. The part thats not working is the delete part...
<?php
session_start();
include 'config.php';
include 'opendb.php';
$SESSION['modifyform'] = $POST;
$modifycat = $POST['modifycat'];
if(isset($GET['del']))
{
$query = "DELETE FROM {$SESSION['modifyform']['modifycat']} WHERE id = '{$GET['del']}'";
mysql_query($query) or die('Error : ' . mysql_error());
exit;
}
?>
Ive searched everywhere but no solution
the error i come up with is
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 'WHERE id = '3'' at line 1
If i put a table name where "{$_SESSION['modifyform']['modifycat']}" , it works fine.
I use the same variable in a "SELECT FROM" query, and it works fine, if i echo "{$_SESSION['modifyform']['modifycat']}" it comes up with the correct value
this is the link which calls the query
<a href="javascript:delArticle('<?php echo $id;?>', '<?php echo $item_name;?>');">delete</a>
and heres the javascript
<script language="JavaScript">
function delArticle(id, item_name)
{
if (confirm("Are you sure you want to delete '" + item_name + "'"))
{
window.location.href = 'modify.php?del=' + id;
}
}
</script>
Can anyone point me in the right direction?