Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > vBulletin 3 Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
[Fix How to] PHP 5 and array_merge errors
Brad
Join Date: Nov 2001
Posts: 4,765

 

Show Printable Version Email this Page Subscription
Brad Brad is offline 08-29-2006, 10:00 PM

If you've upgraded to php 5 on your server you may have seen some of your plug-in's and add-ons throwing errors like this:

Quote:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /index.php(486) : eval()'d code on line 79
This is a common error, we updated our server to php 5 yesterday and I've already seen the error come up twice for two plug-ins on our forum. Another site on the server is running vBadvanced, its news module also threw the same error.

The reason this came up is due to a change in the way array_merge works in php 5. Basically it will no longer accept anything but an array without throwing an error. Thankfully it's just an 'incorrect usage' error and our code still works as it should, it just throws an error now.

The correct way to fix this is not using array merge with anything but arrays. However we already have a lot of code lying around doing things like this:

PHP Code:
$var 'option1';
$array = array('option2''option3''option4');

$array array_merge($var$array); 
Obviously most of us aren't looking to re-write some of this code just so it works under php 5. Thankfully there is a very simple fix for this that won't force us to change much of anything.

Just change your code so it looks like this:

PHP Code:
$var 'option1';
$array = array('option2''option3''option4');

$array array_merge((array)$var$array); 
Notice the (array) next to $var now? That is the only change needed. Your code should now work under php 5 and no longer throw array_merge errors.
Reply With Quote
  #22  
Old 04-28-2008, 10:19 PM
gbox master gbox master is offline
 
Join Date: Dec 2007
Posts: 108
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

lucky me i am not the only noob with this problem

does anybody knows what i can do with this error

Code:
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /index.php(537) : eval()'d code on line 23
i see that you guys have #1 but i have #2
so shoot me i dont know what this meens
give me a hammer and i will build you a house
but php is not my thing
Reply With Quote
  #23  
Old 05-29-2008, 09:56 AM
kafi kafi is offline
 
Join Date: Apr 2004
Posts: 379
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you for this thread, it helped me so much:

originally I have got erorr on member.php

I found that the error was here:

fetch_userinfo plugin vBShout [Template Cache]

original
PHP Code:
if (VB_AREA == "Forum")
{
    global 
$globaltemplates;

    
$globaltemplates  array_merge($globaltemplates, array('forumhome_vbshout'));

changed to

PHP Code:
if (VB_AREA == "Forum")
{
    global 
$globaltemplates;

    
$globaltemplates  array_merge((array)$globaltemplates, array('forumhome_vbshout'));

Everything works fine now .-)
Reply With Quote
  #24  
Old 06-24-2008, 09:09 PM
Rocc Rocc is offline
 
Join Date: Mar 2008
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Fatal error: Call to a member function query_write() on a non-object in /home/iwarezne/public_html/forums/includes/functions.php(1385) : eval()'d code on line 13
Anyone know howto fix it/
Reply With Quote
  #25  
Old 07-29-2008, 02:25 PM
basskiller basskiller is offline
 
Join Date: Jan 2003
Posts: 122
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kafi View Post
Thank you for this thread, it helped me so much:

originally I have got erorr on member.php

I found that the error was here:

fetch_userinfo plugin vBShout [Template Cache]

original
PHP Code:
if (VB_AREA == "Forum")
{
    global 
$globaltemplates;

    
$globaltemplates  array_merge($globaltemplates, array('forumhome_vbshout'));

changed to

PHP Code:
if (VB_AREA == "Forum")
{
    global 
$globaltemplates;

    
$globaltemplates  array_merge((array)$globaltemplates, array('forumhome_vbshout'));

Everything works fine now .-)
thanks.. this fixed mine as well
Reply With Quote
  #26  
Old 10-05-2008, 01:17 PM
danward's Avatar
danward danward is offline
 
Join Date: Dec 2006
Posts: 49
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Really helpful thread big thanks! :up:
Reply With Quote
  #27  
Old 11-17-2008, 07:53 PM
McCarron McCarron is offline
 
Join Date: Apr 2006
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by basskiller View Post
thanks.. this fixed mine as well
This also fixed mine, thanks much!
Reply With Quote
  #28  
Old 02-11-2009, 07:55 PM
daz1967's Avatar
daz1967 daz1967 is offline
 
Join Date: Mar 2007
Location: birmingham
Posts: 51
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Brad View Post
If you're having problems finding the code throwing the error you probably shouldn't be poking around in the files in the first place. At the very least you shouldn't be acting all high and mighty and calling my thread "shit".

Try asking nicely for help, and add a please, and include full error messages and I'll try to help you.

Yes I'm an ass hole, but only when provoked. I'm pretty friendly if you come at me with respect.



You have an error in one of your plug-ins at the hook located at line 1259 of /includes/functions.php.

Open functions.php and locate that line, on it you'll find a line of code similar to this one:

PHP Code:
($hook vBulletinHook::fetch_hook('hook_name')) ? eval($hook) : false
In the above example "hook_name" is the name of the hook location we need to find.

Once you have the name of the hook location go into the plug-in manager in the admincp and find all plug-ins using that location. The code throwing the error is located in one of them.
Thank you Brad, the info you posted help me sort a problem I had put up with for a while
Reply With Quote
  #29  
Old 03-24-2009, 10:49 AM
casper04 casper04 is offline
 
Join Date: Jun 2006
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When i restore my database, I got this problem:
I cannot login the Admincp and it informed
Code:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in /includes/functions.php(1259) : eval()'d code on line 3
My VB is 3.6.8
Can you help me?
Reply With Quote
  #30  
Old 01-17-2010, 03:32 PM
shiola's Avatar
shiola shiola is offline
 
Join Date: Apr 2005
Location: UK
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've got this error since my server got upgraded to PHP5.

Code:
Warning: array_merge() [function.array-merge]: Argument #1 is not an array in [path]/includes/functions.php(1385) : eval()'d code on line 3
I've read through all these answers but still have no idea what I need to fix or how to fix it. Line 3 of functions.php is || ####

I've searched functions.php for hook locations but there's quite a few, so how do I know which one is the error?

I've stuck (array) into every occurance of array_merge on functions.php but this did nothing.

Any ideas?
Reply With Quote
  #31  
Old 01-20-2010, 10:16 PM
shiola's Avatar
shiola shiola is offline
 
Join Date: Apr 2005
Location: UK
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:07 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05063 seconds
  • Memory Usage 2,317KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (3)bbcode_code
  • (7)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete