Warning: Invalid error type specified - showing in output

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Warning: Invalid error type specified - showing in output

Post by nidheeshchandran »

am getting this warning "Warning: Invalid error type specified " for this php line

Code: Select all

trigger_error('Please use the locale view helper: $view->locale()->toDateTime()', 'E_USER_DEPRECATED');
pls help .. thanks.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Warning: Invalid error type specified - showing in outpu

Post by VladSun »

Error types are integers: http://www.php.net/manual/en/errorfunc.constants.php
Not strings ...
There are 10 types of people in this world, those who understand binary and those who don't
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Re: Warning: Invalid error type specified - showing in outpu

Post by nidheeshchandran »

am a newbie :( .. can u pls tell what changes shd i do in that code ? :roll:
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Warning: Invalid error type specified - showing in outpu

Post by VladSun »

You're a newbie - so read some manuals
http://php.net/manual/en/function.trigger-error.php
Take a look at the examples - it's easy isn't it ;)
There are 10 types of people in this world, those who understand binary and those who don't
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Re: Warning: Invalid error type specified - showing in outpu

Post by nidheeshchandran »

thanks .. but i dint understood

do u mean this one

Code: Select all

    trigger_error('Please use the locale view helper: $view->locale()->toDateTime()', E_USER_DEPRECATED);
but in that way am getting 2 errors.

Notice: Use of undefined constant E_USER_DEPRECATED - assumed 'E_USER_DEPRECATED'

Warning: Invalid error type specified
and that's why i changed E_USER_DEPRECATED to 'E_USER_DEPRECATED'
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Warning: Invalid error type specified - showing in outpu

Post by VladSun »

E_USER_DEPRECATED (integer) User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error(). since PHP 5.3.0
There are 10 types of people in this world, those who understand binary and those who don't
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: Warning: Invalid error type specified - showing in outpu

Post by cpetercarter »

E_USER_DEPRECATED is available only in php 5.3.0 + . I guess you are using an earlier php version.

You get 2 error messages. The first tells you that there is no constant E_USER_DEPRECATED (see above)

Then php says "Well maybe he meant to use a string 'E_USER_DEPRECATED'", and tries it. And that produces the second error message, which says in effect "you can't use a string here, you need an integer'".

Moral : you cant use trigger_error() with an error type which is not recognised by your php version.
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Re: Warning: Invalid error type specified - showing in outpu

Post by nidheeshchandran »

i had used another error type E_WARNING

so now first error msg gone .. .but the 2nd invalid error type still shows .. i just want to hide this msg .. page load perfectly and everything fine .. i dont knw for what this error msg and why is it showing ?

can u pls tell more details .. thanks ...
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Re: Warning: Invalid error type specified - showing in outpu

Post by nidheeshchandran »

Code: Select all

    trigger_error('Please use the locale view helper: $view->locale()->toDateTime()', E_WARNING);
now am using this .. but still it show one warning "Warning: Invalid error type specified"

i want to hide this warning .. what can i do .. sorry for the double post i forget to post the script
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: Warning: Invalid error type specified - showing in outpu

Post by VladSun »

http://php.net/manual/en/function.trigg ... .php[quote] Parameters
error_type

The designated error type for this error. It only works with the E_USER family of constants, and will default to E_USER_NOTICE.[/quote]

RTFM! You wasted 12 hours trying to make it work instead of reading the manual for 5 minutes ...
There are 10 types of people in this world, those who understand binary and those who don't
nidheeshchandran
Forum Newbie
Posts: 6
Joined: Thu Nov 11, 2010 3:11 am

Re: Warning: Invalid error type specified - showing in outpu

Post by nidheeshchandran »

:D

actually what i need is remove that warning from output .. and i waste my time .. i deleted that line

Code: Select all

trigger_error('Please use the locale view helper: $view->locale()->toDateTime()', E_WARNING);
and now everything fine .. :D

thats all i need .. thanks ..

actually can u tell for what this trigger error for ?
Post Reply