Delet from a server using php

hey there im wanting to delete from my database using php im new to php and would like help
this is my 2 pages
remove_data.php:

[code]

<?php

include ‘config.php’;
include ‘navigator.php’;
?>

<?php $result = mysql_query("select * from `ting` ORDER BY `ting`.`id` ASC ");

while ($row = mysql_fetch_array($result)) {
echo “

\n”;
echo “\n";
echo “\n";
echo “\n";
echo “\n";
echo “\n";
echo “\n”;
}
?> Fjern Ting: [/code]

remove.php:
[php]<?php
include ‘config.php’;

$sql=“DELETE FROM ting (id)
VALUES
(’$_POST[id]’)”;

if (!mysql_query($sql,$con))
{
die('Error: ’ . mysql_error());
}
echo "1 record deleted ";
echo “Hjem”;

mysql_close($con);
?>
[/php]

thank you for your help

Navn Placering Type Andet ID
”. $row[‘navn’]."”. $row[‘placering’]."”. $row[‘type’]."”. $row[‘andet’]."”. $row[‘id’]."

your MySQL delete query is wrong. It should be in the following syntax:

DELETE FROM table WHERE field=value

In your case:

DELETE FROM ting WHERE id=$_POST[‘id’]

can you tell me how to put it into what i currently got, because i have no clue :wink:

In your second code you have $sql=“DELETE…” just replace the bit in quotes with what I put.

still not working this is the error

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a9119823/public_html/remove.php on line 4
line 4 is where your code is

what exactly is line 4. It looks like you’ve missed something in the switch

Sponsor our Newsletter | Privacy Policy | Terms of Service