The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Unexpected error
All-
When running an app to create users and posts, I get this error: <br /><strong>Warning</strong>: Invalid argument supplied for foreach() in <strong>[path]/includes/functions.php</strong> on line <strong>6501</strong><br />av8or1 1 However if I simply comment out the require_once() statements in the "main" source file: Code:
//require_once( './global.php' ); //require_once( LMDIR . '/DatabaseOps.php' ); //require_once( LMDIR . '/AddNewUser.php' ); //require_once( LMDIR . '/AddNewCategory.php' ); //require_once( LMDIR . '/AddNewForum.php' ); //require_once( LMDIR . '/AddNewThreadPost.php' ); So. Anyone else encountered this before and can help? I did a search, the result of which centered around rebuilding your forum counters and such. I did that but with no change. Thanks! |
#2
|
|||
|
|||
This is a script you wrote yourself (as opposed to one of the vb scripts)? I think you have to define $phrasegroups as an array (and probably define a couple other arrays as well) before including global.php (see the top of any vb page script, like maybe showthread.php)
|
#3
|
|||
|
|||
Hi-
Yes, this is the "main" (ergo top-level) script for a utility that I am finishing up to migrate a Lefora forum to vBulletin. I looked at a few examples of top level scripts, especially the impex stuff and tried to follow suit. I don't recall seeing anything about $phrasegroups, but that is indeed the relevant section of code where the failure occurs. I will go back and take another look, I could have easily missed something. BTW, this failure occurs no matter which require statement is used, either the global script or my own modules. If any of those lines are uncommented, boom, I get the error. What is interesting is that the simplistic version of the db code that immediately follows these require_once statements produces the correct results. By commenting out these require_once statements the error disappears and I still see the same correct results. Wha-? This: Code:
$conn = mysql_connect( $lmConfig[ 'dbserver' ], $lmConfig[ 'username' ],$lmConfig[ 'password' ] ); $lmDB = mysql_select_db( $lmConfig[ 'vbdatabase' ] ); $query = 'SELECT * FROM ' . $lmConfig[ 'vbtableprefix' ] . 'user'; $resultSet = mysql_query( $query ); while( $row = mysql_fetch_array( $resultSet ) ) { print $row['username'] . " " . $row['userid'] ."\n"; } mysql_close( $conn ); Code:
admin 1 joeuser 2 testuser 3 Thanks! |
#4
|
||||
|
||||
What the heck is LMDIR and how did you get that working?
|
#5
|
|||
|
|||
Quote:
ETA: also, there's more than one global.php, so maybe the example script you looked at used a different one than you're including (there's on in admincp, for instance). |
#6
|
|||
|
|||
Ah yes, sorry for omitting that. LMDIR is a variant of the vB CWD and the impex IDIR. Those definitions call getcwd() and if it returns something, they use that value else '.' - LMDIR is set to the full path to the vB forum directory (/home2/username/www/forum in my case) as defined in the config file. When I execute the script I am in this directory.
I didn't mention it previously only because it didn't seem relevant. I get the error even when I reduce the require_once statement to: Code:
require_once( './global.php' ); Code:
require_once( './global.php' ); //require_once( LMDIR . '/DatabaseOps.php' ); //require_once( LMDIR . '/AddNewUser.php' ); //require_once( LMDIR . '/AddNewCategory.php' ); //require_once( LMDIR . '/AddNewForum.php' ); //require_once( LMDIR . '/AddNewThreadPost.php' ); Code:
/* * Constants * * These definitions are used as per the * recommendations of vbulletin support */ define( 'VB_AREA', 'External' ); define( 'SKIP_SESSIONCREATE', 1 ); define( 'SKIP_USERINFO', 1 ); Eh, there I go again talking about code I know little about ... kinda like talking out of my backside. And I don't like doing that. Anyway, I needed to get something up and working so I tried various derivations as any programmer ultimately does. And as I mentioned I commented out all of the aforementioned require_once statements and that - to my surprise - returned the correct result set with no errors. But I dunno ... just didn't seem "right" somehow, so I conducted a search on vb.org ... not much turned up, so I decided to post and ask those who are in-the-know. Thanks again! --------------- Added [DATE]1304524776[/DATE] at [TIME]1304524776[/TIME] --------------- Quote:
I set the directory to be the top-level vB directory prior to the global include. And I am in that top-level vB directory when I type "php LMigrate.php"... Thank you for the feedback, much appreciated! --------------- Added [DATE]1304534406[/DATE] at [TIME]1304534406[/TIME] --------------- Ok I figured out what the problem was, but don't know enough about the vB code to say why. The problem does indeed lie with these lines of code: Code:
/* * Constants * * These definitions are used as per the * recommendations of vbulletin support */ define( 'VB_AREA', 'External' ); define( 'SKIP_SESSIONCREATE', 1 ); define( 'SKIP_USERINFO', 1 ); Thanks! --------------- Added [DATE]1304550656[/DATE] at [TIME]1304550656[/TIME] --------------- Quote:
PHP Code:
'Still don't know exactly what SKIP_USERINFO does, but I'll get back to that. Right now I've got other higher priority stuff to work on, such as completing the migration. (!) There is another fellow Lefora user who is fed up and wants to bail, and I've agreed to help. But I digress. Thanks again! |
Thread Tools | |
Display Modes | |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|