View Full Version : Displaying a Custom Error Message??
The-Ensemble
03-03-2008, 08:06 AM
In the admincp file for the hack I'm doing, if the foreach functions return empty it returns
Warning: Invalid argument supplied for foreach() in /admincp/X.php on line 67
How could I change that to display a html wrapped message customized by me? Such as 'This Section Currently Has No Information' ?
Thanks. :up:
Dismounted
03-03-2008, 10:04 AM
Check if the array you're looping has any data beforehand.
The-Ensemble
03-03-2008, 10:13 AM
Nope, empty. I normally would of thought it'd be something like
if(empty($var))
{
error message
}
But I've no idea how to apply that to a foreach and Its not a variable.
Opserty
03-03-2008, 02:33 PM
Look in the vBulletin AdminCP files and see how they display their errors, then just duplicate this in your conditional. (They use fetch_error() and another function print_cp_message(), I think) Look them up in the API manual: vBulletin 3.6 Code Documentation (http://members.vbulletin.com/api/).
You may have to create a phrase the "Error Messages" Phrasegroup.
Dismounted
03-04-2008, 04:14 AM
Nope, empty. I normally would of thought it'd be something like
if(empty($var))
{
error message
}
But I've no idea how to apply that to a foreach and Its not a variable.
If it's not a variable, then it can't be applied with the foreach language construct. That's what's giving you the error. If the supplied var is empty, foreach just skips it.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.