vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Displaying a Custom Error Message?? (https://vborg.vbsupport.ru/showthread.php?t=171961)

The-Ensemble 03-03-2008 08:06 AM

Displaying a Custom Error Message??
 
In the admincp file for the hack I'm doing, if the foreach functions return empty it returns

Quote:

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

PHP Code:


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.

You may have to create a phrase the "Error Messages" Phrasegroup.

Dismounted 03-04-2008 04:14 AM

Quote:

Originally Posted by The-Ensemble (Post 1455809)
Nope, empty. I normally would of thought it'd be something like

PHP Code:


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.


All times are GMT. The time now is 04:13 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02180 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete