Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-23-2006, 10:32 PM   PM User | #1
PureMisery
New Coder

 
Join Date: Dec 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
PureMisery is an unknown quantity at this point
Mysql Error Messages

Is there a way to change the way a mysql error message is displayed?
Example:
A current mysql error msg:
Code:
Warning: mysql_connect(): Can't create a new thread (errno 11). 
If you are not out of available memory, you can consult the manual for a possible OS-dependent bug in
hsphere/local/home/ACCOUNT_NAME/MYRANDOMSITE.com/path/to/file.php on line 4
Is there a way to hide the section that displays my account name?
PureMisery is offline   Reply With Quote
Old 09-24-2006, 01:08 AM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Using PHP? Then just use the str_replace() function on mysql_error().

PHP Code:
echo str_replace('hsphere/local/home/ACCOUNT_NAME/MYRANDOMSITE.com'''mysql_error()); 
__________________
Fumigator is offline   Reply With Quote
Old 09-24-2006, 02:15 AM   PM User | #3
PureMisery
New Coder

 
Join Date: Dec 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
PureMisery is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
Using PHP? Then just use the str_replace() function on mysql_error().

PHP Code:
echo str_replace('hsphere/local/home/ACCOUNT_NAME/MYRANDOMSITE.com'''mysql_error()); 
I tried this but it didn't work.
PHP Code:
$connect mysql_connect($dbhost$dbuname$dbpass)
            or die(
"Unable to connect to MySql Server");
$dbselect mysql_select_db($dbname,$connect)
            or die(
"Could not select table");
echo 
str_replace('/hsphere/local/home/ACCOUNT_NAME/'''mysql_error($connect)); 
And yes, I did change ACCOUNT_NAME
PureMisery is offline   Reply With Quote
Old 09-24-2006, 05:21 AM   PM User | #4
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
What does "it didn't work" mean? Did your computer implode? Did the jerbil inside die? Did the internet crash?

The code you posted won't ever get to your echo statement if there is a connection error due to your "or die()" code, so I reckon mysql_error() isn't going to return much if the connection works, so I'm not sure what you're going for there.
__________________
Fumigator is offline   Reply With Quote
Old 09-24-2006, 05:58 AM   PM User | #5
PureMisery
New Coder

 
Join Date: Dec 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
PureMisery is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
What does "it didn't work" mean? Did your computer implode? Did the jerbil inside die? Did the internet crash?

The code you posted won't ever get to your echo statement if there is a connection error due to your "or die()" code, so I reckon mysql_error() isn't going to return much if the connection works, so I'm not sure what you're going for there.
When I say it doesn't work, I mean that there was no change in the displayed error message. I tried it with and without the "or die()" code.
PureMisery is offline   Reply With Quote
Old 09-24-2006, 06:57 AM   PM User | #6
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
My first response was off the cuff; now I've thought about it. The function mysql_connect() will display a warning if it fails, which you can completely suppress using the "@" sign just before the function name.
PHP Code:
$connect = @mysql_connect($dbhost$dbuname$dbpass); 
You can leave it like that if you don't need anything at all displayed, or you can now put the str_replace thing in to modify the error message. You may find that mysql_error() itself doesn't show the relative path to the file, which is what you were originally concerned with. (It will display username which you probably don't want either)
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:04 PM.


Advertisement
Log in to turn off these ads.