Forum Moderators: coopster
I have included in my where the items from the db are displayed the following code.
echo "<a href='delete.php?id=".$row{'id'}."'>";
echo "DELETE";
echo "</a></span></td>";
now I created a script that will delete the items based on their ID i have included the code for the script below:
<?php
include 'dbconnect.php';
$id = $_GET['id']
$sqlquery = "DELETE * FROM tnews WHERE id='".$id."')";
header("Location: display.php");
//print $sqlquery;
$results = mysql_query($sqlquery);
mysql_close($dbc);
?>
Now the error I am getting is as follows:
Parse error: parse error, unexpected T_VARIABLE in H:\wwwdir\Apache2\htdocs\delete.php on line 6
line 6 being, now line 6 is:
$sqlquery = "DELETE * FROM tnews WHERE id='".$id."')";
can anyone here help me to get this to work correctly? I would appreciate it an awful lot.
[edited by: bysonary at 5:22 pm (utc) on Nov. 15, 2006]
here is the full code including the dbconnect.php include
$username = "root";
$password = "password";
$server = "localhost";
$dbname = "cb2cwh";
$dbc = mysql_connect($server, $username, $password) or die ("ERROR");
$select = mysql_select_db($dbname, $dbc) or die("couldn't connect");
$id = $_GET['id'];
$sqlquery = "DELETE * FROM tnews WHERE id='$id'";
header("Location: display.php");
//print $sqlquery;
$results = mysql_query($sqlquery);
mysql_close($dbc);
?>
this should delete an item from the table tnews with the id in the url for instance if the url is delete.php?id=5 it would delete the item from the database with the id of 5?
it isnt deleting anything?