phpBB2Refugees.com Logo
Not affiliated with or endorsed by the phpBB Group

Register •  Login 

Continue the legacy...

Welcome to all phpBB2 Refugees!Wave Smilie

This site is intended to continue support for the legacy 2.x line of the phpBB2 bulletin board package. If you are a fan of phpBB2, please, by all means register, post, and help us out by offering your suggestions. We are primarily a community and support network. Our secondary goal is to provide a phpBB2 MOD Author and Styles area.

Request Help for "Unsupported operand types" [PHP


 
Search this topic... | Search General Support... | Search Box
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Author Message
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Tue Jun 14, 2011 8:29 am 
Post subject: Request Help for "Unsupported operand types" [PHP

Hello,
I always get a blank page with the following error line, when i try to make a certain operation:

Fatal error: Unsupported operand types in /home/root/MOD_newposts_number.php on line 295

I went to check this file... at line 295, and here it is the whole part:

Code:
      // START no forum reads no topic reads


         // FINAL
         // COUNT EVERY post from LAST session... ( no topic has been seen yet.. )
            $sql3 = "SELECT COUNT(post_id) as total
               FROM " . POSTS_TABLE . "
               WHERE post_time >= " . $last_visit . "
               AND poster_id != " .$userdata['user_id']."
               AND forum_id IN (".$read_forum_sql60.")";


         if ( !($result3 = $db->sql_query($sql3)) )
         {
            message_die(GENERAL_ERROR, 'Could not query number of newposts information', '', __LINE__, __FILE__, $sql);
         }

         while( $row3 = $db->sql_fetchrow($result3) )
         {
            $total += $row3['total'];
         }

         // Parse output ..
         $lang['Search_new'] = $lang['Search_new'] . " (" . $total . ")";

      }
      // END no forum reads no topic reads

Among the part, the line 295 is this: $total += $row3['total'];

I have no idea from which original mod is this part... too many mods installed over the past 5 years icon_sad.gif but doing a little research on google I have found out that the file "MOD_newposts_number.php" seem to be related to the mod: "View number of new posts since last visit"

http://www.phpbb.com/customise/db/mod/view_number_of_new_posts_since_last_visit/

http://www.phpbb.com/community/viewtopic.php?f=15&t=354358

Can anyone help me to solve this error?
I recently upgraded to PHP 5.3.5, maybe its related to that?

Thanks in advance for a possible help...
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Tue Jun 14, 2011 9:22 am 
Post subject: Re: Request Help for "Unsupported operand types" [

icon_redface.gif icon_redface.gif
solved the problem.. somehow

I reuploaded the file MOD_newposts_number.php
downloaded from the phpbb pages above
and which was anyway identical in size to the old one,
but apparently, now I get no more error!

very very strange.... icon_rolleyes.gif but anyway, it seems solved icon_biggrin.gif
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Tue Jun 14, 2011 11:25 am 
Post subject: Re: Request Help for "Unsupported operand types" [

It seemed solved...
but sometimes it works, sometimes I get the error...

icon_rolleyes.gif I have no idea how this can happen, maybe the forum is possessed by ghosts.
Back to top
lumpy burgertushie
Board Member



Joined: 19 Nov 2008

Posts: 214


flag
PostPosted: Tue Jun 14, 2011 12:51 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

depending on how old that code is, it could be related to the php upgrade.
I know that I have some old scripts that no longer work with php5x

I have no idea how to fix it though.

luck,
robert
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Tue Jun 14, 2011 2:31 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Can you echo/var_dump $row3['total']? Make sure you get both the value when it works and when it doesn't. May be worth echoing the $total as well to make sure.
Also, what field type is 'total' in your database?
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Tue Jun 14, 2011 7:16 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Salvatos wrote:
Can you echo/var_dump $row3['total']? Make sure you get both the value when it works and when it doesn't. May be worth echoing the $total as well to make sure.
Also, what field type is 'total' in your database?
Sorry Salvatos, but you are speaking chinese for me icon_redface.gif icon_redface.gif

icon_mrgreen.gif as you can see, i'm not that good in these matters...
Do you mean I should go to phpmyadmin and enter the database to do the things you tried to explain above? icon_smile.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Wed Jun 15, 2011 2:57 am 
Post subject: Re: Request Help for "Unsupported operand types" [

I'm sorry, it's hard to guess how good with PHP everyone here is icon_smile.gif
In the code you posted,

FIND
Code:
while( $row3 = $db->sql_fetchrow($result3) )
         {
            $total += $row3['total'];
         }


REPLACE WITH
Code:
while( $row3 = $db->sql_fetchrow($result3) )
         {
            echo "total: $total + $row3['total']<br />";
            $total += $row3['total'];
         }

That will display something like this on your page:
total: a + b
total: c + d
etc.

I don't think we'll have to do the other part of what I posted, though, I think I'm beginning to get an idea of what the problem may be. Finding a solution will be another matter, though; we'll see about that when we know for sure icon_wink.gif
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Wed Jun 15, 2011 8:06 am 
Post subject: Re: Request Help for "Unsupported operand types" [

hmmm Salvatos,
I tried to replace that code with your "replacement" code
but now when I open the forum I get this:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/root/MOD_newposts_number.php on line 295


Probably you have made a typo or a little mistake in that code? icon_smile.gif
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Wed Jun 15, 2011 5:06 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Sorry about that, must be the array. Change this line:

echo "total: " . $total . " + " . $row3['total'] . "<br />";
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Wed Jun 15, 2011 6:19 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Thanks

Now the index page loads, and I get "total: + 0" at top-left corner.

When I am In this condition the operation I make NEVER work.
Because when I make that operation (which is to launch the file phoogle_map.php) I get a blank page with:

total: Array + 0

Fatal error: Unsupported operand types in /home/root/MOD_newposts_number.php on line 296


Where line 296 is of course:

$total += $row3['total'];

---------------------------------------------------
Now, I have just discovered that TO MAKE things work in every condition and in every session,
I have to FIRST go to view a topic, (viewtopic.php)
and then If i make the same operation (launch phoogle_map.php) from index page, after I've been to viewtopic, it works in every condition, and I dont get anymore error messages!

But ONLY after I view/read a topic.

Strange, very strange....
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Wed Jun 15, 2011 9:52 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Interesting, I was expecting an array, but I didn't think it would be $total. I'm mostly shooting in the dark here, but I think this will work:

ON LINE 278, ADD
Code:
         $total = 0;


If I'm correct, that should be it icon_razz.gif If it works, you can remove the "echo" line, of course.
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Wed Jun 15, 2011 10:27 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Salvatos wrote:
Interesting, I was expecting an array, but I didn't think it would be $total. I'm mostly shooting in the dark here, but I think this will work:

ON LINE 278, ADD
Code:
         $total = 0;


If I'm correct, that should be it icon_razz.gif If it works, you can remove the "echo" line, of course.


Indeed great !! icon_mrgreen.gif

it works in every condition now, and I get a:
total: 0 + 0

It's time to delete the echo.... icon_biggrin.gif

Thanks so much Salvatos! You're great
Back to top
Salvatos
Board Member



Joined: 19 Feb 2009

Posts: 414
Location: Québec


flag
PostPosted: Wed Jun 15, 2011 11:53 pm 
Post subject: Re: Request Help for "Unsupported operand types" [

Awesome icon_smile.gif

If it stopped working after you upgraded PHP, they probably changed the way variable declaration works. Since it wasn't declared, it used to assume it was just empty, now it assumes it's an empty array (which causes the operand error).
Back to top
dondino
Board Member



Joined: 09 Dec 2008

Posts: 144


flag
PostPosted: Thu Jun 16, 2011 7:28 am 
Post subject: Re: Request Help for "Unsupported operand types" [

Salvatos wrote:
Awesome icon_smile.gif

If it stopped working after you upgraded PHP, they probably changed the way variable declaration works. Since it wasn't declared, it used to assume it was just empty, now it assumes it's an empty array (which causes the operand error).
I think you're right there! I've never experienced any problems before the upgrade, and I did THAT operation quite often...
So I'm quite sure this strange behaviour only came up after php upgrade (5.3.5).
Unfortunately its always a pain with such upgrades... but from time to time they need to be done...
icon_rolleyes.gif
Back to top
Display posts from previous:   
Register or Login to Post    Index » General Support  Previous TopicPrint TopicNext Topic
Page 1 of 1 All times are GMT
 
Jump to:  

Index • About • FAQ • Rules • Privacy • Search •  Register •  Login 
Not affiliated with or endorsed by the phpBB Group
Powered by phpBB2 © phpBB Group
Generated in 0.0207 seconds using 15 queries. (SQL 0.0017 Parse 0.0006 Other 0.0184)
phpBB Customizations by the phpBBDoctor.com
Template Design by DeLFlo and MomentsOfLight.com Moments of Light Logo