Jump to content

Recommended Posts

I have a commenting system on my website. I have it so that each comment is approved before it is posted live on the site. I have an admin center that displays all the comments and lets me Approve, Disprove, and Ban any comments.  I have it set so if you approve it changes the database so that it will display it live. If I Disprove the comment it will delete it from the database. If I Ban it I want to delete it then insert the users IP into another database so that that user cannot post any more comments (sort of  a spam filter). This is what I have so far but it does not work and I believe this syntax is invalid.

 

<?php
$sql = "DELETE FROM comm WHERE comment_ID = '$comment_id'";
		$sql2 = "INSERT INTO `ban_com` (`id`, `usr_ip`) VALUES ('', '$usr_ip')";
		if(mysql_query($sql) && mysql_query($sql2)) {
			echo "<p>Removed Comment</p>";
		}	
?>

Ok I have a table that is called COMMENTS inside that table I have a bunch of rows (id, post_id, comment_author, comment_author_email, comment_author_IP, comment_date, comment_content) The primary key in that table is ID and auto_increment.

 

Another table is called BANNED_COMM inside that I just have (id, banned_ip) primary key is ID. I want to delete the entries from COMMENTS and then place only the comment_author_IP into the BANNED_COMM. Do I need something in common with the two tables for this to work?

Here is my table layouts:

 

CREATE TABLE `comments` (
  `comment_ID` bigint(20) unsigned NOT NULL auto_increment,
  `comment_post_ID` bigint(20) unsigned NOT NULL default '0',
  `comment_author` tinytext NOT NULL,
  `comment_author_email` varchar(100) NOT NULL default '',
  `comment_author_IP` varchar(100) NOT NULL default '',
  `comment_date` datetime NOT NULL default '0000-00-00 00:00:00',
  `comment_date_gmt` datetime NOT NULL default '0000-00-00 00:00:00',
  `comment_content` text NOT NULL,
  `comment_approved` enum('Yes','No') NOT NULL default 'No',
  `comment_agent` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`comment_ID`),
  KEY `comment_approved` (`comment_approved`),
  KEY `comment_post_ID` (`comment_post_ID`),
  KEY `comment_approved_date_gmt` (`comment_approved`,`comment_date_gmt`),
  KEY `comment_date_gmt` (`comment_date_gmt`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;

CREATE TABLE `banned_comments` (
  `id` int(55) NOT NULL auto_increment,
  `usr_ip` char(15) NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.