Author |
Message |
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Tue Jun 14, 2011 4: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 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
|
Posted: Tue Jun 14, 2011 5:22 am Post subject: Re: Request Help for "Unsupported operand types" [ |
|
|
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.... but anyway, it seems solved |
|
Back to top |
|
|
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Tue Jun 14, 2011 7:25 am Post subject: Re: Request Help for "Unsupported operand types" [ |
|
|
It seemed solved...
but sometimes it works, sometimes I get the error...
I have no idea how this can happen, maybe the forum is possessed by ghosts. |
|
Back to top |
|
|
lumpy burgertushie Board Member
Joined: 18 Nov 2008
Posts: 266
|
Posted: Tue Jun 14, 2011 8:51 am 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: 449 Location: Québec
|
Posted: Tue Jun 14, 2011 10:31 am 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
|
Posted: Tue Jun 14, 2011 3: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
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? |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Tue Jun 14, 2011 10:57 pm Post subject: Re: Request Help for "Unsupported operand types" [ |
|
|
I'm sorry, it's hard to guess how good with PHP everyone here is
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 |
|
Back to top |
|
|
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Wed Jun 15, 2011 4: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? |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Wed Jun 15, 2011 1: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
|
Posted: Wed Jun 15, 2011 2: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: 449 Location: Québec
|
Posted: Wed Jun 15, 2011 5: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
If I'm correct, that should be it If it works, you can remove the "echo" line, of course. |
|
Back to top |
|
|
dondino Board Member
Joined: 09 Dec 2008
Posts: 144
|
Posted: Wed Jun 15, 2011 6: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
If I'm correct, that should be it If it works, you can remove the "echo" line, of course. |
Indeed great !!
it works in every condition now, and I get a:
total: 0 + 0
It's time to delete the echo....
Thanks so much Salvatos! You're great |
|
Back to top |
|
|
Salvatos Board Member
Joined: 19 Feb 2009
Posts: 449 Location: Québec
|
Posted: Wed Jun 15, 2011 7:53 pm Post subject: Re: Request Help for "Unsupported operand types" [ |
|
|
Awesome
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
|
Posted: Thu Jun 16, 2011 3:28 am Post subject: Re: Request Help for "Unsupported operand types" [ |
|
|
Salvatos wrote: | Awesome
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...
|
|
Back to top |
|
|
|