Zero2Cool
14 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
14 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
14 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
14 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
14 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
14 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
14 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
14 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
14 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
14 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
packerfanoutwest (7h) : 49ers are underdogs at Packers, ending streak of 36 straight games as favorites
Zero2Cool (15h) : 49ers might be down their QB, DL, TE and LT?
packerfanoutwest (22-Nov) : Jaire Alexander says he has a torn PCL
Zero2Cool (20-Nov) : Even with the context it's ... what?
Mucky Tundra (20-Nov) : Matt LaFleur without context: “I don’t wanna pat you on the butt and you poop in my hand.”
beast (20-Nov) : We brought in a former Packers OL coach to help evaluate OL as a scout
beast (20-Nov) : Jets have been pretty good at picking DL
Zero2Cool (20-Nov) : He landed good players thanks to high draft slot. He isn't good.
Zero2Cool (20-Nov) : He can shove his knowledge up his ass. He knows nothing.
beast (20-Nov) : More knowledge, just like bring in the Jets head coach
Zero2Cool (19-Nov) : What? Why? Huh?
beast (19-Nov) : I wonder if the Packers might to try to bring Douglas in through Milt Hendrickson/Ravens connections
Zero2Cool (19-Nov) : The Jets fired Joe Douglas, per sources
packerfanoutwest (19-Nov) : Jets are a mess......
Zero2Cool (19-Nov) : Pretty sure Jets fired their scouting staff and just pluck former Packers.
Zero2Cool (19-Nov) : Jets sign Anders Carlson to their 53.
Zero2Cool (19-Nov) : When you cycle the weeks, the total over remains for season. But you get your W/L for that selected week. Confusing.
packerfanoutwest (19-Nov) : the total and percentage are the same as the previous weeks
packerfanoutwest (19-Nov) : the total and percentage are the same as the previous weeks
packerfanoutwest (19-Nov) : the totals are accurate..nrvrtmind
Zero2Cool (19-Nov) : I don't follow what you are saying. The totals are not the same as last week.
packerfanoutwest (19-Nov) : ok so then wht are the totals the same as last week?
Zero2Cool (19-Nov) : NFL Pick'em is auto updated when NFL Scores tab is clicked
Martha Careful (19-Nov) : The offense was OK. Let's not forget the Bear defense is very very good.
packerfanoutwest (19-Nov) : Who updates the leaderboard on NFLPickem?
beast (19-Nov) : Has the Packers offense been worse since the former Jets coach joined the Packers?
Zero2Cool (19-Nov) : Offense gets his ass in gear, this could be good.
Zero2Cool (19-Nov) : Backup QB helped with three wins. Special Teams contributed to three wins.
bboystyle (18-Nov) : Lions played outside thats why. They scored 16 and 17 in the only 2 outside games this year
Zero2Cool (18-Nov) : The rest of the NFL is catching up to Packers ... kicking is an issue throughout league
packerfanoutwest (18-Nov) : Packers DL Kenny Clark: We knew 'we were going to block' Bears' game-winning field goal attempt
Zero2Cool (18-Nov) : Lions seem to be throttling everyone, but only (only) got 24 lol maybe the rain is why
Zero2Cool (18-Nov) : Packers vs Lions game doesn't seem so bad.
beast (18-Nov) : Dennis Green "They are what we thought they were, and we let them off the hook!"
Martha Careful (17-Nov) : comment of the day Z2Cool "Bears better than we want to admit. Packers worse than we think. It's facts."
Mucky Tundra (17-Nov) : my worst case scenario: Bears fix their oline and get a coach like Johnson from the Lions and his scheme
Zero2Cool (17-Nov) : Bears get OL fixed amd we might have a problem
buckeyepackfan (17-Nov) : Pretty sure they already have scouting reports on guys who aren't even starting for their college team. The future is now for me.
buckeyepackfan (17-Nov) : I tend to let Gute and Co. Worry about the future.
beast (17-Nov) : That's great news and Packers need to keep upgrading their OL, DL and DBs this off-season, so missing one guy doesn't kill them
beast (17-Nov) : That's great news and Packers need to keep upgrading their OL, DL and DBs this off-season, so missing one guy doesn't kill them
buckeyepackfan (17-Nov) : Jaire and Evans Williams are both ACTIVE! Good news.
Martha Careful (17-Nov) : The badgers really need to change the whole offensive scheme. No draws no screens plus the quarterback is marginal
Cheesey (17-Nov) : If the Badgers had a decent QB, they would have won. The guy can't hit a wide open receiver
Martha Careful (17-Nov) : chop block
Martha Careful (17-Nov) : there was a very questionable job Block call that upon viewing replay was very borderline
beast (17-Nov) : How so? (I didn't watch)
Zero2Cool (17-Nov) : Badgers got hosed vs Oregon
packerfanoutwest (16-Nov) : damn,he hasn't played since week 2
Mucky Tundra (15-Nov) : poor guy can't catch a break
Please sign in to use Fan Shout
2024 Packers Schedule
Friday, Sep 6 @ 7:15 PM
Eagles
Sunday, Sep 15 @ 12:00 PM
COLTS
Sunday, Sep 22 @ 12:00 PM
Titans
Sunday, Sep 29 @ 12:00 PM
VIKINGS
Sunday, Oct 6 @ 3:25 PM
Rams
Sunday, Oct 13 @ 12:00 PM
CARDINALS
Sunday, Oct 20 @ 12:00 PM
TEXANS
Sunday, Oct 27 @ 12:00 PM
Jaguars
Sunday, Nov 3 @ 3:25 PM
LIONS
Sunday, Nov 17 @ 12:00 PM
Bears
Sunday, Nov 24 @ 3:25 PM
49ERS
Thursday, Nov 28 @ 7:20 PM
DOLPHINS
Thursday, Dec 5 @ 7:15 PM
Lions
Sunday, Dec 15 @ 7:20 PM
Seahawks
Monday, Dec 23 @ 7:15 PM
SAINTS
Sunday, Dec 29 @ 12:00 PM
Vikings
Saturday, Jan 4 @ 11:00 PM
BEARS
Recent Topics
1h / Green Bay Packers Talk / wpr

16h / Green Bay Packers Talk / Martha Careful

21-Nov / Green Bay Packers Talk / Martha Careful

21-Nov / Green Bay Packers Talk / Zero2Cool

21-Nov / Green Bay Packers Talk / Zero2Cool

21-Nov / Green Bay Packers Talk / Zero2Cool

21-Nov / Green Bay Packers Talk / beast

20-Nov / Green Bay Packers Talk / Zero2Cool

20-Nov / Green Bay Packers Talk / Zero2Cool

20-Nov / Green Bay Packers Talk / beast

20-Nov / Green Bay Packers Talk / wpr

19-Nov / Green Bay Packers Talk / dfosterf

19-Nov / Featured Content / Zero2Cool

19-Nov / Green Bay Packers Talk / Martha Careful

19-Nov / Green Bay Packers Talk / wpr

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