Is there a way to change the way a mysql error message is displayed?
Example:
A current mysql error msg:

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

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.

PureMisery

09-24-2006, 05:58 AM

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.

Fumigator

09-24-2006, 06:57 AM

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.

$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)