PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 19th, 2007, 06:35 AM
Bartel Bartel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Location: Belgium
Posts: 2 Bartel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 57 sec
Reputation Power: 0
'Catch' php error messages?

Hello,

I'm new to this forum, and pretty new to php, as well. I do have some C# experience, but that doesn't help me solve the following:

I need to check for a valid mysql connection, but I don't want to see any php warnings or errors. (That's why I'm checking myself, so I can decide what to do when there's a problem.

The code:
PHP Code:
if (Connect('root''wrongpassword')) {
    echo 
"Connection ok!";
    }
else {
    echo 
"Connection not ok!";
}

function 
Connect($user$pass){
    if (
mysql_connect('localhost',$user,$pass)) {
        return 
1;    
    } 
    else {
        return 
0;
    }



Later on, I will switch to adodb, but I guess the problem will remain the same (well I actually checked already). Using try/catch doesn't solve it either.

This is probably a simple problem for most php developers, but I'm stuck! I already tried some example code found via Google, but to no use. The return values are okay, the warnings keep popping up.

Thanks for helping me out...

Bartel

Reply With Quote
  #2  
Old May 19th, 2007, 07:40 AM
Humanetainit's Avatar
Humanetainit Humanetainit is offline
Beyond help
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: The Netherlands
Posts: 222 Humanetainit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 1 h 32 m 30 sec
Reputation Power: 12
Do you want to hide the php errors?
use
PHP Code:
if (@mysql_connect('localhost',$user,$pass)) { ... } 

or use
PHP Code:
 error_reporting(0); 
at the top of the script.
__________________
One World... Humanetainit | Program secure

Reply With Quote
  #3  
Old May 19th, 2007, 02:55 PM
Bartel Bartel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2007
Location: Belgium
Posts: 2 Bartel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 5 m 57 sec
Reputation Power: 0
At least the '@' symbol cannot be found in the index of my PHP manual. A sorry excuse, but better than nothing! ;-)

Thanks!

Reply With Quote
  #4  
Old May 23rd, 2007, 01:25 PM
ehsan's Avatar
ehsan ehsan is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Location: North York, ON, Canada
Posts: 65 ehsan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 h 43 m 44 sec
Reputation Power: 13
Send a message via MSN to ehsan Send a message via Yahoo to ehsan Send a message via Google Talk to ehsan Send a message via Skype to ehsan
If you had typed "err" in the index keyword finder text field, you could have found about '@' symbol usage. Topic that covers about this is "Error Control Operators".

Thanks

Quote:
Originally Posted by Bartel
At least the '@' symbol cannot be found in the index of my PHP manual. A sorry excuse, but better than nothing! ;-)

Thanks!

Reply With Quote
  #5  
Old May 26th, 2007, 05:55 PM
monkey56657 monkey56657 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2006
Posts: 78 monkey56657 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 38 m 21 sec
Reputation Power: 13
also look at

http://uk2.php.net/set-error-handler
__________________



Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > 'Catch' php error messages?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap