Wow I can't see the difference, but I did get it working before seeing this. Unfortionately I also get these 2 errors, lol.
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in W:\www\includes\database.php on line 502
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in W:\www\includes\database.php on line 509
Here's the code I managed to make. I put it under the first query and it works really really well, but like I said I get 2 stubborn errors, lol.
[code:1] if (count($results)>10){
$query = "DELETE FROM #__liveshoutbox WHERE nameid = '66'"
. "ORDER BY id ASC LIMIT 1";
$database->setQuery($query);
$cleanup = $database->loadObjectList();
}
[/code:1]
I'll try what ya posted and see what happens.
*update* Ok what I had first attempted and you fixed does work, but it deletes much more then wanted. The second approach works perfectly in handling the deletion, BUT it gives those 2 errors. So now to figure out how to get them to go away, lol.
*update* Ok I got it to check the users own count everytime they visit a profile or visit their own. This will ensure other users can't trigger another users update deletion. It works flawlessly except for the same 2 stupid errors, which I have no clue why they appear.
Here's the queries (takes 2)
[code:1]
$check = "SELECT *"
. "\n FROM #__liveshoutbox"
. "\n WHERE nameid=".$my->id;
$database->setQuery( $check );
$cleancount = $database->loadObjectList();
if (count($cleancount)>10){
$query = "DELETE FROM #__liveshoutbox WHERE nameid=".$my->id." "
. "ORDER BY id ASC LIMIT 1";
$database->setQuery($query);
$cleanup = $database->loadObjectList();
}
[/code:1]
If you know how to combine the 2 queries into 1 that'd be cool, but I don't know if it'd work. It's the count that determines if the second should be triggered or not. Otherwise the second query never fires.
Post edited by: krileon, at: 2008/09/25 02:51
Post edited by: krileon, at: 2008/09/25 02:58