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
Zero2Cool (9h) : Chase Young to sign $13M contract with Saints
Zero2Cool (9h) : Yosh to Panthers what noooo. Wait he didn't do crap
wpr (18-Mar) : I say that he is technically HER BIL as he married her sister. I checked it out, he's considered my BIL as well. Sad.
Mucky Tundra (18-Mar) : wpr, I assume its your BIL via marriage to your wife? If so, I can figure out where the smarts in the family went ;)
wpr (18-Mar) : Mucky my B-I-L is Bare Stupid. I could write a book.
Mucky Tundra (18-Mar) : As a teenager in Rockford IL I would get heckled by adults in public for wearing GB gear
Mucky Tundra (18-Mar) : if you think the online ones are bad, try *living amongst* them
Mucky Tundra (18-Mar) : Never doubt wprs loyalty. Poor guy is surrounded by Bears fans in Northern IL
wpr (17-Mar) : pass Martha. Thanks for the invite though.
Martha Careful (17-Mar) : blog * as the same ugly Illinois colors were adopted by the Baer
Martha Careful (17-Mar) : WPR, perhaps you should be joining the Bears fans blog has the same ugly Illinois colors were adopted by the Bears
Mucky Tundra (17-Mar) : Ah a fellow U of Illinois hater. I can respect that though I imagine it's for different reasons
Zero2Cool (17-Mar) : BTW. I didn't catch the game. I just hate Illinois.
Mucky Tundra (17-Mar) : They're your Big Ten Chumps and you will like it!
Zero2Cool (17-Mar) : No, not for the record. Referee's handled that BS. Orange team was trash ass
Mucky Tundra (17-Mar) : *Your* Big Ten Chumps for the record
Zero2Cool (17-Mar) : No, not Big Ten Champs. IL is big ten CHUMPS
wpr (17-Mar) : Big Ten Champs
wpr (17-Mar) : !!!
wpr (17-Mar) : INI
wpr (17-Mar) : ILL
Martha Careful (17-Mar) : Wisconsin with an outstanding on in the men’s Big Ten basketball tournament. Let’s hope it continues in the NCAAs
Zero2Cool (17-Mar) : Almost like taking QB in 2020 even if you don't need one is good move.
Mucky Tundra (16-Mar) : 2021 QB Draft class looking like a real clunker
Mucky Tundra (16-Mar) : A conditional 6th rounder? I remember Bears fans arguing they'd get a day 2 pick at worst lol
dfosterf (16-Mar) : So I got the no extension part right and the have to wait on the CW physical wrong
Zero2Cool (16-Mar) : Bears are trading Justin Fields for a 2025 6th-round pick that goes to a 4th-round pick based on playtime, per sources.
Zero2Cool (16-Mar) : Former Packer Jarrett Bush opens Wisconsin’s first blow dry bar in Green Bay
dfosterf (16-Mar) : If the Bears are not doing a deal with Washington, they also cannot trade Fields until Williams physical with them. All hail Caleb Williams!
dfosterf (16-Mar) : The talent is undeniable, but the (advertised) haul is obscene.
dfosterf (16-Mar) : If the Bears are cutting a deal with the Commanders, in either scenario, cannot happen until williams passes a Commanders physical
dfosterf (16-Mar) : My guess is no to the Fields extension, but yes to the trade back with the Commanders.
dhazer (15-Mar) : I think the Bears do a Love extension and they will trade out of the 1st pick and take the haul
Martha Careful (15-Mar) : that might make sense
Zero2Cool (15-Mar) : Justin Fields to Steelers?
Zero2Cool (15-Mar) : Kenny Pickett. Eagles. Done.
Zero2Cool (15-Mar) : They can claim best two WR tandem.
Mucky Tundra (15-Mar) : Aaron Donald retiring
dhazer (15-Mar) : Campbell signing with 49ers
dhazer (15-Mar) : I love how the Bear Fans are now claiming they have the best skill players in the NFC North lol
Zero2Cool (15-Mar) : Vikings made a move to get a 2nd first round pick
Mucky Tundra (15-Mar) : That's a not a bad deal for the Bears
Zero2Cool (15-Mar) : Bears have traded for WR Keenan Allen sending Chargers a fourth rounder.
Martha Careful (15-Mar) : *signs
Martha Careful (14-Mar) : MLB Devon White science with the Eagles
Mucky Tundra (14-Mar) : But that was before FA started
Mucky Tundra (14-Mar) : Dhaze, I thought Kurls would be their #1 target when I read that he was an Amos comp (jack of all trades guy)
dhazer (14-Mar) : I would like to see the Packers target 2 more FA still available Kamren Curl Safety and Chase Young edge
Martha Careful (14-Mar) : wow...didn't see that coming
Zero2Cool (14-Mar) : AJ Dillon re-signing with Packers.
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 / beast

14h / Green Bay Packers Talk / dfosterf

15h / Green Bay Packers Talk / beast

18-Mar / Around The NFL / Mucky Tundra

16-Mar / Random Babble / Martha Careful

16-Mar / Green Bay Packers Talk / TheKanataThrilla

15-Mar / Green Bay Packers Talk / dhazer

15-Mar / Green Bay Packers Talk / dfosterf

14-Mar / Green Bay Packers Talk / beast

14-Mar / Random Babble / Zero2Cool

14-Mar / Green Bay Packers Talk / dfosterf

13-Mar / Random Babble / Zero2Cool

13-Mar / Green Bay Packers Talk / Martha Careful

13-Mar / Green Bay Packers Talk / Martha Careful

13-Mar / Green Bay Packers Talk / beast

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