Wrong parameter count for strrpos() in

Events happening in the community are now at Drupal community events on www.drupal.org.
matthew_ellis24's picture

Hi there, I've been setting up this module and so far all the important bits have gone perfectly to plan. However when I enable the recent forum topics block I get the following error:
warning: Wrong parameter count for strrpos() in /home/content/c/a/r/carabusonline/html/drupal/sites/all/modules/phpbb/phpbb.module on line 662.

Most of the topics display properly, but one is displayed as an elipsis (...). I don't really understand what this bit of the code is doing. But the title it can't display is:
unidentified Carabus from Kyoto Japan.

Drupal 5.6
phpBB 3 rc5

Many thanks

Comments

You're probably still using

arkepp's picture

You're probably still using PHP 4?

I don't have any installations with PHP 4, so there are probably a few bugs like this. You can either try fixing them yourself (they're easy, just go to php.net and compare the function in PHP 4 with the one in PHP 5) or you can step through them with me (I give you a patch for this one, and you'll find the next one, and so on).

Either way, please post back your results.

hmmm, odd I thought my host

matthew_ellis24's picture

hmmm, odd I thought my host used php5, but yes you're right, it's set to php 4.3.11, looks like godaddy has had issues with 5.

I had a look and php.net says strrpos is supported from 4.0.0 up so not sure why it's upset. I saw somewhere else that someone recommended initializing the variable so I set
$a_row=1;
on line 658, which didn't make any difference.

This is from the php.net discussion, and sounds relevant but I'm not sure how to implement it

<php
        $pos = strlen(string $haystack) - strpos (strrev(string $haystack), strrev(string $needle)) - strlen(string $needle);
?>

         If in the needle there is more than one character then in php 4 we can use the above statement for finding the position of last occurrence of a substring in a string instead of strrpos. Because in php 4 strrpos uses the first character of the substring.

eg :
<php
        $haystack = "you you you you you";
        $needle = "you";
        $pos1 = strlen($haystack) - strpos (strrev($haystack), strrev($needle)) - strlen($needle);
        echo $pos1 . "<br>";
        $pos2 strrpos($haystack, $needle);
        echo $pos2 . "<br>";
?>

http://us3.php.net/manual/en/

arkepp's picture

http://us3.php.net/manual/en/function.strrpos.php :
Note that the needle in this case can only be a single character in PHP 4

I've swapped the existing

matthew_ellis24's picture

I've swapped the existing line 662:
$pos = strrpos($a_row['topic_title'], " ", - (strlen($a_row['topic_title']) - $cc));

For this one, which seems to work with things the way they are at the minute. I understand the version you did, but the one below doesn't make sense to me...but it works?!

$pos = strlen($a_row['topic_title']) - strpos ($a_row['topic_title'], strrev(" ")) - $cc;

Hello, I had the same

manojn's picture

Hello,
I had the same problem while setting up > mas.org.in
Here's what i did to get around it.
Open the file > phpbb_block_recent_topics.inc.php
and comment out line no. 46
//$pos = strrpos($a_row['topic_title'], " ", - (strlen($a_row['topic_title']) - $cc));

Then modify line no. 47 to look like so:
$descstr = substr($a_row['topic_title'],0,$cc) . "...";

Thats it! :)

phpbb

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week