Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
[PHP5] How to disable "Notice: Undefined Variable"
Old 04-01-2010, 02:18 PM [PHP5] How to disable "Notice: Undefined Variable"
kids's Avatar
Ultra Talker

Posts: 301
Trades: 0
Hi all,

My codes is working fine, but when I have upgraded to PHP5 (localhost), it's always show up "Notice: Undefined Variable...", I don't see any wrong in this case. An all of pages are working fine.

I wanna disable that notice, but don't know how to do.

Please help! Thanks
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
kids is offline
Reply With Quote
View Public Profile Visit kids's homepage!
 
 
Register now for full access!
Old 04-01-2010, 03:47 PM Re: [PHP5] How to disable "Notice: Undefined Variable"
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
In your php.ini set error_reporting to E_ALL & ~E_NOTICE
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-02-2010, 12:47 AM Re: [PHP5] How to disable "Notice: Undefined Variable"
MattGoucher's Avatar
Skilled Talker

Posts: 64
Name: Matt
Location: California
Trades: 0
Although NullPointer is correct, you might not want to disable the error message on every page that you have PHP on. Sometimes those errors can be helpful. I would advise that you use the method below:
PHP Code:
<?php
    
echo ini_get('display_errors');

    if (!
ini_get('display_errors')) {
        
ini_set('display_errors'1);
    }

    echo 
ini_get('display_errors');
?>
More info on how to use the ini_set method here:

http://us2.php.net/manual/en/function.ini-set.php
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Invalid Code On A New Website Is Like Having A New Car With A Broken Windshield
MattGoucher is offline
Reply With Quote
View Public Profile Visit MattGoucher's homepage!
 
Old 04-02-2010, 02:47 AM Re: [PHP5] How to disable "Notice: Undefined Variable"
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
The error_reporting and display_errors directives are not the same. The code you copied from the documentation will turn on error reporting if it is off, but it doesn't do anything with regard to whether notices are reported.

If you want to use ini_set to turn off the reporting of notices do it like this:
PHP Code:
ini_set('error_reporting'E_ALL & ~E_NOTICE); 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 04-02-2010, 05:58 AM Re: [PHP5] How to disable "Notice: Undefined Variable"
Super Talker

Posts: 139
Name: John Davis
Trades: 0
Also you can use @ char before variable name (like @$yourvariable) to hide any message.
__________________
»
Please login or register to view this content. Registration is FREE
- Interactive maps for websites
»
Please login or register to view this content. Registration is FREE
for web developers
MapMaster is offline
Reply With Quote
View Public Profile Visit MapMaster's homepage!
 
Old 04-03-2010, 02:02 PM Re: [PHP5] How to disable "Notice: Undefined Variable"
kids's Avatar
Ultra Talker

Posts: 301
Trades: 0
Quote:
Originally Posted by NullPointer View Post
In your php.ini set error_reporting to E_ALL & ~E_NOTICE
Done as you guide, but still showing up the awful msg!
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by kids; 04-03-2010 at 08:16 PM..
kids is offline
Reply With Quote
View Public Profile Visit kids's homepage!
 
Old 04-03-2010, 09:24 PM Re: [PHP5] How to disable "Notice: Undefined Variable"
Average Talker

Posts: 17
Name: Dejan
Location: Macedonia
Trades: 0
what about error_reporting?


PHP Code:
error_reporting(0); 

Last edited by DeJaaaN; 04-03-2010 at 09:25 PM..
DeJaaaN is offline
Reply With Quote
View Public Profile Visit DeJaaaN's homepage!
 
Old 04-04-2010, 07:27 AM Re: [PHP5] How to disable "Notice: Undefined Variable"
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Would it not be simpler to fix the problem???


there will be a line of code where you use a variable that has not been defined, often caused by mis-spelling a variable name in a statement.

You don't see any other problems because PHP instantiates the variable as NULL and if the code is not doing any calculations with the variable it will not cause any other errors.

I would suggest you are looking for a GET or POST key that does not exist.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to [PHP5] How to disable "Notice: Undefined Variable"
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.43100 seconds with 12 queries