Forum Moderators: coopster
<?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']}" is it works fine.
Can anyone point me in the right direction?
A couple of things
1) If you are getting values from $_POST and then in your if{} condition you are checking for a $_GET ? i am not sure if both of them will work together ?
2) why not simply
<?php
$modifycat = $_POST['modifycat'];
$id=$_POST['del'];
if(isset($_POST['del']))
{
$query = "DELETE FROM $modifycat WHERE id = $id";
mysql_query($query) or die('Error : ' . mysql_error());
exit;
}
?>
That makes it easier to work with, if it still does not work then try to echo your $query before execution to see if the generated query is fine
[edited by: Anyango at 6:21 am (utc) on Dec. 6, 2008]
<a href="javascript:delArticle('<?php echo $id;?>', '<?php echo $item_name;?>');">delete</a>