another one ... im stumped!<

liunx

Guest
ok so im making a script to delete posts ive made.


<html>
<?
$mysql_server = "localhost";
$mysql_user = "morrowasted";
$mysql_password = "*******";
$server = "localhost";
mysql_connect ($mysql_server, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db ("www");
$query = mysql_query("SELECT * FROM ltc");
while($row = mysql_fetch_array($query)) {
echo $row["id"] . "\||/"; // those are seperators, just so you know
echo $row["story"] . "\||/";
echo $row["author"] . "<br>";
}
$del = strip_tags(addslashes($_POST["del"]));
if ($_SERVER['REMOTE_ADDR']==$_SERVER['SERVER_ADDR']){
if ($_POST['del'] !==""){
mysql_query("DELETE FROM ltc WHERE id = $del") or die(mysql_error());
}
}

mysql_close();


?>
<form action="ltcadmin.php" method="post">
DELETE WHERE ID = <input type="text" name="del"><br>
<input type="submit" value="DELETE">
</form>


its displaying all the stuff, but im getting this 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 '' at line 1

and my form isnt showing up at all :/Instead of this...

DELETE FROM ltc WHERE id = $del

Use...

DELETE FROM ltc WHERE id='$del'

So now it becomes...


mysql_query("DELETE FROM ltc WHERE id='$del'") or die(mysql_error());if ($_POST['del'] !==""){

should be

if ($_POST['del'] != ""){thanks guys, works now!
 
Back
Top