Page 1 of 1

Not Deleting Record

Posted: Sun Jun 27, 2010 10:38 am
by gazzieh
The following code is a section from a SWITCH command that should delete a record from the relevant table:

Code: Select all

$deletQuery = "DELETE FROM ".$settings['tbl_articles']." WHERE ID = ".$HTTP_GET_VARS['id'];
			if ($result = $connector->query($deleteQuery))
				{
				header("Location: index.php");
				}
			else
				{
				echo "DELETE FROM ".$settings['tbl_articles']." WHERE ID = ".$HTTP_GET_VARS['id'];
				echo('<center>Sorry, there was an error deleting from the database</center>');
				}
The resultant instruction is given as DELETE FROM tblarticles WHERE ID = 2, which, if I enter directly into mySQL does indeed delete the record with the ID = 2. Yet, all this does is select the ELSE instruction.

The section of code used for the actual query is:

Code: Select all

// Execute a database query
	function query($query)
		{
		$this->theQuery = $query;
		return mysql_query($query, $this->link);
		}
Any ideas why this keeps failing?

Re: Not Deleting Record

Posted: Sun Jun 27, 2010 11:30 am
by mikosiko
gazzieh wrote:$deletQuery = "DELETE FROM ".$settings['tbl_articles']." WHERE ID = ".$HTTP_GET_VARS['id'];
         if ($result = $connector->query($deleteQuery))
I see a clear problem in the previous 2 lines..... $deletQuery <> $deleteQuery

Re: Not Deleting Record

Posted: Sun Jun 27, 2010 11:44 am
by gazzieh
mikosiko wrote:
gazzieh wrote:$deletQuery = "DELETE FROM ".$settings['tbl_articles']." WHERE ID = ".$HTTP_GET_VARS['id'];
         if ($result = $connector->query($deleteQuery))
I see a clear problem in the previous 2 lines..... $deletQuery <> $deleteQuery
OMG! I spent sooo long looking and didn't see the obvious at all!

Thank you so much.