PDA

View Full Version : Hulp With Delete Script



Johnnikins
03-08-2008, 06:50 PM
Okay, i have a delete script which should work


<?php
$hostname = "localhost";
$db_user = "*******"; // change to your database password
$db_password = "*******"; // change to your database password
$database = "*******"; // provide your database name
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);

$ref = $_GET['RefNum'];
$ok = @mysql_query("DELETE FROM ads WHERE REFNUM='$ref");

if ($ok) {

echo("Advert Deleted");

} else {
echo('<p>Error deleting from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}

?>

I go to delete it and it says deleted, yet when i check to see if it has deleted it hasn't

Help please?

also here is my table structure if it is any help

http://feudel.co.uk/images/advertise/uploads/img4895fddd094f9saga.PNG

Trigs
04-08-2008, 08:47 PM
DELETE _ FROM

your missing whatever is in between DELETE and FROM

Excellent
04-08-2008, 08:50 PM
Okay, i have a delete script which should work


<?php
$hostname = "localhost";
$db_user = "*******"; // change to your database password
$db_password = "*******"; // change to your database password
$database = "*******"; // provide your database name
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);

$ref = $_GET['RefNum'];
$ok = @mysql_query("DELETE FROM ads WHERE REFNUM='$ref");

if ($ok) {

echo("Advert Deleted");

} else {
echo('<p>Error deleting from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}

?>I go to delete it and it says deleted, yet when i check to see if it has deleted it hasn't

Help please?

also here is my table structure if it is any help

http://feudel.co.uk/images/advertise/uploads/img4895fddd094f9saga.PNGAre you looking to delete 1 reference number at a time or actually remove the RefNum table from the database?

MrCraig
04-08-2008, 08:56 PM
<?php
$hostname = "localhost";
$db_user = "*******"; // change to your database password
$db_password = "*******"; // change to your database password
$database = "*******"; // provide your database name
$db = mysql_connect($hostname, $db_user, $db_password);
mysql_select_db($database,$db);

$ref = $_GET['RefNum'];
$ok = @mysql_query("DELETE FROM `ads` WHERE `RefNum` = '$ref'");

if ($ok) {

echo("Advert Deleted");

} else {
echo('<p>Error deleting from database!<br />'.
'Error: ' . mysql_error() . '</p>');
}
mysql_close($db);
?>

Johnnikins
06-08-2008, 12:50 AM
thanks everyone, i got it working eventually :D

Want to hide these adverts? Register an account for free!