Hi i am Trying to delete a page from my site cms

and something is not working .

the code is:

<?php
 $con = mysql_connect("localhost","matanc_cmd","123123");
 if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }

mysql_select_db("matanc_cms", $con);


$id = (int) $_POST['id'];

mysql_query("DELETE FROM content WHERE id='$id'");
mysql_close($con);


// if successfully updated.
if($result){

echo "Successful";

 echo "<BR>";
 echo "<a href='show.php'>View result</a>";
}



 ?> 

What is wrong ?
when i want to delete a page i go to the delete.php?id=XX (XX = ID of the page)

Recommended Answers

All 5 Replies

Have PHP tell you what mysql doesn't like:

if($result) {
  // echo success info
}  else {
    echo mysql_errno($con) . ": " . mysql_error($con). "\n";
}

still dont work

OK. Try putting this test before the if($result)... test.

if (mysql_errno()) { 
   $error = "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n$query\n<br>";
}

still not worke

when i want to delete a page i go to the delete.php?id=XX (XX = ID of the page)
$id = (int) $_POST['id'];

This should be

$id = (int) $_GET['id'];
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.