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?

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

$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

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.