Jump to content


Photo

php delete problem


  • Please log in to reply
2 replies to this topic

#1 chuddyuk

chuddyuk
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationEngland

Posted 02 July 2006 - 04:11 PM

Before anyone says it, iv tried searchin the forum to see if i can work out why my script isnt working, but had no luck. its a simple one anyway:

im trying to delete records from my db using this code:
<?
include "connect.php";

$id = $_REQUEST['id'];

$query = "DELETE FROM gallery WHERE id = '$id'";
$query = mysql_query($sql) or die("Cannot query the database.<br>" . mysql_error());
echo "Database Updated.";

?>
I get the error:
Cannot query the database.
Query was empty
anyone know where im going wrong? :)

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 02 July 2006 - 04:13 PM

Your assigning your query to a variable called $query, then executing a query with the variable $sql.

Try...
$result = mysql_query($query) or die("Cannot query the database.<br>" . mysql_error());


#3 chuddyuk

chuddyuk
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationEngland

Posted 02 July 2006 - 04:16 PM

Your a star mate, it was staring me right in the face. Much Appriceated!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users