0

I have tried several combinations and just can't get this right. I am getting "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 '* FROM bookmarks WHERE bid = 11' at line 1" when I click the URL.
Here is the href: <a href="deleterecord.php?bmID=<?php echo $rowbm;?>">Delete</a>

And here is the PHP:

<?php
include "connect.php";
if(!isset($_SESSION['uname'])){

header("location:login.php");
}

if(isset($_GET['bmID'])){
if(is_numeric($_GET['bmID'])){

$id = mysql_real_escape_string($_GET['bmID']);
$del = "DELETE * FROM users WHERE bid = $id";
if(mysql_query($del)){
header("location:main.php");
}else{
echo mysql_error();
}
}
}
?>

I'm sure it is something simple but I am still learning so I have an excuse :) Could someone help me out please?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by Tekkno
0

$del = "DELETE * FROM users WHERE bid = $id";

apply single qoutes around ur '$id', some times $id doesnt contain any value due to any reason so the query goes to databse is like

DELETE * FROM users WHERE bid =

and this cause syntax error

0

Its DELETE FROM users WHERE bid = $id . Notice how the * is missing. You only need the quotes around the value if it's not a number.

0

Its a mysql error. Read the mysql manual about DELETE. The answer is pretty obvious.

Thanks for the help keith, you were absolutely right. Runs fine now. I will remember that.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.