Zero2Cool
13 years ago
In the posts table, I have 13,155 posts.
The software shows 12,989.

I have 166 posts that were deleted, but not removed from the database??

Edit, actually it means I have 13,155 post ID's, but only 12,989 posts with a text.
UserPostedImage
Zero2Cool
13 years ago
[php]
SELECT _fpro_posts_text.post_id
FROM _fpro_posts, _fpro_posts_text
WHERE _fpro_posts.poster_id='2'
AND _fpro_posts_text.post_id != _fpro_posts.post_id
[/php]

Shouldn't this display a list of posts_text.post_id's that do not have a corresponding posts.posts_id for the poster_id 2?
UserPostedImage
Zero2Cool
13 years ago
This is hopeless. There's a ton of NULL's under id 2, okay, 136 or so, but I can't delete them records!
UserPostedImage
djcubez
13 years ago
From what you say this forum software works like other forum software with a POSTS table, a MEMBERS/USERS table and a TOPICS table. Each of them refer to each other by an auto-incremented value (topicID, postID and memberID). If you want to delete all the posts from members that don't exist you'd have to use multiple queries. For example:


<?php

// establish variables
$memberposts = "0";
$nonmemberposts = "0";

// first query all posts
$post_query ="SELECT * FROM posts";
$post_result = mysql_query($post_query);
while($post_row = mysql_fetch_array($post_result)) {
	// now we can address each post individually
	// we should set some variables we need
	$postID = $post_row["id"];				// The post ID
	$memberID = $post_row["memberid"];		// The member that made this post
	$isMember = true;						// boolean for whether the member exists or not
	// now we need to figure out if the member with that id still exists
	// to do that you need to do a num_rows query
	$member_query = "SELECT * FROM members WHERE id='$memberID'";
	$member_count = mysql_num_rows($member_query);
	// check if it returns a result
	if($member_count < "1") {
		// the member does not exist
		$isMember = false;
	}
	// now we return the result of our script
	if($isMember) {
		// post verified
		$memberposts++;
	} else {
		// delete the post?
		// I wouldn't
		// $delete_query = "DELETE FROM posts WHERE id='$postID'";
		// mysql_query($delete_query);
		$nonmemberposts++;	
	}
}

// display a report at the end
echo "Total posts by members: " . $membersposts . "<br />total posts by non-members: " . $nonmemberposts;

?>

Obviously you'll have to replace the references I make to mysql rows and tables because I don't know whats yours are exactly. But if I do understand what you want this code should work, although I haven't tested it.

EDIT: Please don't run the script with the delete query in it until you've verified that it works. I would not want you to accidentally delete all the posts in this forum because of my bad code. I've already commented the delete query out so that if you want to you can just comment it back in.
Zero2Cool
13 years ago
Yeah, I don't want to delete them just yet. I want to see them first, that's why I was using the SQL query in the phpAdmin.

I can provide the three tables for you guys if that'll help.
UserPostedImage
dhpackr
13 years ago

<?php

// $delete_query = "DELETE ?????FROM posts WHERE id='$postID'";
		// mysql_query($delete_query);
		$nonmemberposts++;	
?>

wouldn't work if it wasn't commented out, this would cause an error, not telling what you want to delete.

why don't you just delete id #2, the whole row? if you are using auto increment for the id field, it wouldn't let you delete the row unless you delete the id
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
Zero2Cool
13 years ago
I've deleted members in the users table, but not their posts. Therefore there's posts out there that cause errors while searching.
UserPostedImage
dhpackr
13 years ago
imo, the best way to maintain your site would be to manually go into the database through php admin and delete the rows that way.

a script would be nice for maintenance, but you are risking wiping out data you want to keep.

just wondering, did you join the mysql forum. you should, and post questions in the forum.

you'll get your solution...if you are driven.

BTW..I find it humorous, a .NET Developer is running his forum using PHP, Microsoft's main nemesis.

Isn't that like sayin you work at Ford but drive a Toyota?

:icon_smile: just sayin!
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
Zero2Cool
13 years ago
I was looking into developing my own software using ASP-MVC2 with SQL Server, but it seems like too much work. I'd be reinventing a lot of the options here.

Might as well stick with this and enhance it, instead of recreating everything, right?
UserPostedImage
dhpackr
13 years ago
yes, stick with the PHP site. Classic ASP is an old technology. You have to write a ridiculous amount of "spaghetti" code to do even a simple database call.

Microsoft updated to .NET for a reason!
So if you meet me Have some courtesy, Have some sympathy, and some taste
Use all your well-learned politesse, Or I'll lay your soul to waste
Fan Shout
wpr (7h) : Just about time to watch Sonny Weaver stick it to the seahags. I never get tired of it.
Martha Careful (7h) : *game plan
Martha Careful (7h) : IMHO, not even close. He is not a guy you game play around.
Mucky Tundra (10h) : is Aiyuk worth a 1st rounder?
Zero2Cool (10h) : 49ers are seeking a 1st round pick in exchange for WR Brandon Aiyuk
Mucky Tundra (22-Apr) : Based on Gutes comments, now I don't feel as silly having 13 picks in my mock the other day
Zero2Cool (22-Apr) : Zach Wilson to Broncos.
Zero2Cool (22-Apr) : Gutekunst says he'd love to have 13 or 14 picks. He's trading back huh lol
beast (22-Apr) : Someday we'll have a draft betting scandal
beast (21-Apr) : Sometimes looking extremely amazing, sometimes looking extremely lost
beast (21-Apr) : I haven't looked into the QBs, but some have suggested Maye has some of the most extremely inconsistent tape they've seen
beast (21-Apr) : Well it also sounds like Patriots are listening to trade offers, not that seriously considering any, but listening means they aren't locked
Zero2Cool (21-Apr) : Maye needs to be AFC
Mucky Tundra (21-Apr) : Not liking the idea of the Vikings getting Maye
Zero2Cool (21-Apr) : Vikings HC joked that he may or may not have sent flowers to Bob Kraft. That's where rumor came from.
beast (21-Apr) : Can't tell if this is real or BS, but some rumors about a possible Patriots/Vikings trade for #3 overall
dfosterf (21-Apr) : One playbook to my knowledge. I was shooting for facetious.
beast (20-Apr) : I'm not sure they have different playbooks for different OL positions, and Dillard run blocking is supposedly worse than his pass blocking..
dfosterf (19-Apr) : The only problem with that is he isn't a guard either.
dfosterf (19-Apr) : Put him at right guard. That is where he will be coached. That is where he will compete. He is not even allowed to look at the LT playbook.
dfosterf (18-Apr) : Kidding aside, I hope the best for him.
dfosterf (18-Apr) : Went to a Titans board. One comment there. Not very long. I quote: "LOL" They don't sound overly upset about our aquisition.
beast (18-Apr) : OT Dillard has been absolutely horrible... like OG Newman levels
dfosterf (18-Apr) : Suit him up and have him stand in front of the big board as a draft day cautionary tale.
Zero2Cool (18-Apr) : Packers sign T Andre Dillard.
Mucky Tundra (18-Apr) : Adds most of the information this time of year comes from agents.
Mucky Tundra (18-Apr) : @RealAlexBarth Bill Belichick says accurate draft information doesn't leak from teams until about 12 hours before the draft. Adds most of th
Mucky Tundra (18-Apr) : I am very happy that for moment, Jordan Love seems like a normal human being
Zero2Cool (17-Apr) : Belichick * whatever
Zero2Cool (17-Apr) : "There's a lot of depth at Offensive Tackle and Wide Receiver." Bill Bellichick
Zero2Cool (17-Apr) : Thanks! I can't believe it's over haha
Martha Careful (16-Apr) : Congratulations
Zero2Cool (16-Apr) : Boom. Student Loan. $0.00. Only took about 20 years.
Zero2Cool (14-Apr) : Packers DT Kenny Clark: New defensive coordinator Jeff Hafley will 'allow us to be way more disruptive'
Zero2Cool (12-Apr) : Saints have agreed to terms on a contract with former Packers wide receiver Equanimeous St. Brown.
beast (12-Apr) : No, but of it's for legislation, then half of the country will find it evil, not good, whatever it says....
Mucky Tundra (12-Apr) : Draft is still 2 weeks away. UGH
dhazer (11-Apr) : Does anyone know of a good AI generator to create letters of Support for legislation?
Zero2Cool (11-Apr) : Gordon "Red" Batty retires as equipment manager
Zero2Cool (10-Apr) : Sounds like that's pretty certain now.
Zero2Cool (10-Apr) : Packers "at" Eagles in Brazil. Week One
dfosterf (10-Apr) : Va' Fazer As Malas Va' !
Zero2Cool (9-Apr) : Mark Murphy tipping us off?
Zero2Cool (9-Apr) : “We’re either the first- or second-most popular team in Brazil.”
Zero2Cool (9-Apr) : Christian Watson got married. Wife better be careful with those hamstrings!! 😂😂
dfosterf (9-Apr) : Those poor bastards
Zero2Cool (8-Apr) : Falcons have signed former Packers CB Kevin King, who has been out of football since 2021.
dfosterf (8-Apr) : Collectively, we need to spend more time in what we have, when analyzing ostendible needs and historical proclivities
dfosterf (8-Apr) : I say he is better than so many of these draft picks
dfosterf (8-Apr) : Question of the week for me: Has anyone besides me done any deep dive into the potential of Alex McGough, our 3rd string qb?
Please sign in to use Fan Shout
2023 Packers Schedule
Sunday, Sep 10 @ 3:25 PM
Bears
Sunday, Sep 17 @ 12:00 PM
Falcons
Sunday, Sep 24 @ 12:00 PM
SAINTS
Thursday, Sep 28 @ 7:15 PM
LIONS
Monday, Oct 9 @ 7:15 PM
Raiders
Sunday, Oct 22 @ 3:25 PM
Broncos
Sunday, Oct 29 @ 12:00 PM
VIKINGS
Sunday, Nov 5 @ 12:00 PM
RAMS
Sunday, Nov 12 @ 12:00 PM
Steelers
Sunday, Nov 19 @ 12:00 PM
CHARGERS
Thursday, Nov 23 @ 11:30 AM
Lions
Sunday, Dec 3 @ 7:20 PM
CHIEFS
Monday, Dec 11 @ 7:15 PM
Giants
Sunday, Dec 17 @ 12:00 PM
BUCCANEERS
Sunday, Dec 24 @ 12:00 PM
Panthers
Sunday, Dec 31 @ 7:20 PM
Vikings
Sunday, Jan 7 @ 3:25 PM
BEARS
Sunday, Jan 14 @ 3:30 PM
Cowboys
Saturday, Jan 20 @ 7:15 PM
49ers
Recent Topics
6h / Green Bay Packers Talk / wpr

22-Apr / Green Bay Packers Talk / Mucky Tundra

22-Apr / Green Bay Packers Talk / Mucky Tundra

21-Apr / Fantasy Sports Talk / dfosterf

21-Apr / Green Bay Packers Talk / dfosterf

19-Apr / Random Babble / Zero2Cool

18-Apr / Green Bay Packers Talk / Zero2Cool

18-Apr / Random Babble / Mucky Tundra

18-Apr / Green Bay Packers Talk / Mucky Tundra

17-Apr / Green Bay Packers Talk / Mucky Tundra

17-Apr / Green Bay Packers Talk / Mucky Tundra

17-Apr / Green Bay Packers Talk / beast

17-Apr / Green Bay Packers Talk / beast

17-Apr / Green Bay Packers Talk / beast

16-Apr / Random Babble / Martha Careful

Headlines
Copyright © 2006 - 2024 PackersHome.com™. All Rights Reserved.