News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

RemoveTopic.php error!

Started by leegreaves, September 29, 2011, 07:13:16 AM

Previous topic - Next topic

leegreaves

Seem to be getting one of two errors occur in my RemoveTopic.php file.

First up there seems to be an unexpected "}" on line 575 of the php file, now prior to removing it, if I attempted to delete a post or remove a board from my forum it comes up saying there was "an unexpected "}" in RemoveTopic.php

Now Ive removed that "}" thinking this would sort the error out. It improved the situation a bit but not completely. Now this time I was able to remove the board i wanted removed successfully, BUT was still unable to remove a post. This time an error message appears (when attempting to remove a post) informing me the following: "The database value you're trying to insert does not exist: memberid"

Any ideas on what I need to do to resolve this error?

Many thanks!!!

Illori

can you attach your removetopic.php to your next post? also can you include the whole error message including the line number for the first error message?

Ricky.

Also , try to replace it with fresh copy of file from SMF package, do this only when you have no mod installed which may have modified this file.

leegreaves

The first error message has been resolved due to there being an extra "}" at line 575 in the file. Im attaching RemoveTopic.php with this post. What I have discovered is it comes up with the error if there's only the first post in it. If a topic has more than one post in it then I am able to remove ALL posts other than the original first post for that topic.

leegreaves

Quote from: Ricky. on September 29, 2011, 07:35:14 AM
Also , try to replace it with fresh copy of file from SMF package, do this only when you have no mod installed which may have modified this file.

Unfortunately I wont be able to replace it with a fresh copy as i do have mods installed on my site

Illori

your line spacing/endings are incorrect in your file, i dont know what you used to edit it but it makes a diff on the file almost impossible, i would suggest you replace it with a fresh copy unless you can revert the changes to the file so a diff can be complete.

leegreaves

is there a way of correcting the line spacings etc so that i dont have to revert back to a fresh copy of the file?

Kays

Hi, try the attached file. You were missing a closing brace on line 575. The line spacing problem should be fixed also.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

If you read the original post...that closing brace on line 575 is an unexpected brace as I originally reported. Any ideas why its saying that?

leegreaves

Quote from: Kays on September 29, 2011, 09:06:49 AM
Hi, try the attached file. You were missing a closing brace on line 575. The line spacing problem should be fixed also.

Unfortunately now I get a unexpected closing brace error at line 529

Kays

The brace at line 575 is required to close that function. So it needs to be there.

However around line 273, where the shop mod has been added. the braces don't match. Can't quite see what needs to be changed there or if there also problems elsewhere.

Did you just install the shop mod or had it been active for a while?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

I installed the shop mod with the last day or 2. Would it be a good idea to uninstall the shop mod and see what happens then and if all is back to how it should be, reinstall it to see if things are back to how they should be?

Kays

There's another mod in there which looks like it's karma related that has added code in the same area. And the conflict is possibly there.

The best I can tell is that there's an extra closing brace on line 284. Try removing it or commenting it out and see if that will clear the error. It's the last one in this block of code:


// End SMFShop code

if($modSettings['karmaValueThread'] > 0)
$request = $smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET karma_good = karma_good - {int:newkarma}
WHERE id_member = {int:memberid}',
array(
'newkarma' => $modSettings['karmaValueThread'],
'memberid' => $rowMembers['id_member']
)
);
}

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

Ive since removed the shop mod for the time being, I found the extra closing bracket you were on about but when I again attempted to delete a post it came up with "extra } (closing bracket) found at line 1000" as a syntax error

Kays

That means that there's probably a brace missing now which I can't see. ::)

Which Karma mod is that? I'll try to look into it further later on today?

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

Im using Advanced Reputation System 1.8.3

Kays

OK, I see what happening now. With the Advanced reputation mod installed I get errors in that file when I try to install the shop mod. So you must be doing those edits manually. The second edit is fine but not the first one.

What's happening there is that both mods add while loop in the same spot. And you're trying to put the second loop inside the first rather adding it to it.

With the Advanced Rep mod installed, the first search position for the shop mod gets changed to:


while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers))
{
updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));


Add just the following after that


// Begin SMFShop code
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET money = IF(money >= {int:amount}, money - {int:amount}, 0)
WHERE id_member = {int:member}
LIMIT 1',
array(
'amount' => $modSettings['shopPointsPerPost'],
'member' => $rowMembers['id_member'],
));
// End SMFShop code

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

IM assuming that is with the shop mod installed as its not installed at moment as i removed it for the purposes of sorting this current error out...ill reinstall it but i do know that some of the code isnt getting added it has to be done manually. So im guessing that the code youve put there is the way it needs to be done. OK...fingers crossed lol

leegreaves

Right when i go to install the shop mod ive noticed a couple of differences, yes that extra brace is getting added at the end of the mod as part of it but the select code is being // (slashed) out:

Code: (Find) [Select]

         while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers))
            updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));

Code: (Replace) [Select]

         //   while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers))
         //   updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));
            
         // Begin SMFShop code
         while ($rowMembers = $smcFunc['db_fetch_assoc']($requestMembers))
         {
            updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));
            
            global $smcFunc, $modSettings;
            $smcFunc['db_query']('', '
               UPDATE {db_prefix}members
               SET money = IF(money >= {int:amount}, money - {int:amount}, 0)
               WHERE id_member = {int:member}
               LIMIT 1',
               array(
                  'amount' => $modSettings['shopPointsPerPost'],
                  'member' => $rowMembers['id_member'],
               ));
         }
         // End SMFShop code


Im guessing what ur saying is dont remark out the first 2 lines of code and omit the brace at the end of the shop mod?

leegreaves

Right tried to follow what was said here but seem to not work. What ive done instead is remove the shop mod and the advanced reputation mod. I believe these were the only 2 mods out of the addons I had that altered removetopic.php in any way. I had a copy of the small update and copied the file out of the sources file there and replaced the one on my site. This seems to have sorted out the problem of not being able to delete only a single post in a topic.

I do want to reinstall the mods back on my forum, but i think the problem lays in the order i installed them, I installed the shop mod AFTER I had installed the advanced reputation mod and this is what caused my problem. I have a feeling the advanced reputation altered parts of the code in a way the shop mod wasnt expecting and hence the error. Does anyone think that if i install the mods in the reverse order ie SMFShop first followed by the Advanced Reputation System this error shouldnt occur? Does anyone concur with that.

Kays

Rather than trying to explain it, the attached file has the proper edits. Install both mods and then replace the file on your server with this one.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Kays

Rather than trying to explain it, the attached file has the proper edits. Install both mods and then replace the file on your server with this one.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

leegreaves

Since my last post...i seem to have sorted it out. Uninstalled both plugins, replaced my remove topic file with an original 2.0.1 copy of it. The shop mod then installed correctly in the way it was meant to be, it seems to me that both mods (shop mod and the advanced reputation system) were both editing the code in a slightly different manner in order to obtain the result they were trying to achieve. The problem occurred if the code had already been altered, the other mod could not see how to alter the code so that both could work in unison in the same loop. I will attempt to reinstall the advanced reputation system on my forum at a later date but for now everything is working 100%

For now im marking this topic as solved!

Advertisement: