Not Deleting Record

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gazzieh
Forum Commoner
Posts: 40
Joined: Wed May 19, 2010 7:46 am

Not Deleting Record

Post 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?
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Not Deleting Record

Post 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
gazzieh
Forum Commoner
Posts: 40
Joined: Wed May 19, 2010 7:46 am

Re: Not Deleting Record

Post 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.
Post Reply