NYCPHP Meetup

NYPHP.org

[nycphp-talk] mysql_connect() doesn't affect mysql_error()?

Analysis & Solutions danielc at analysisandsolutions.com
Mon Aug 18 11:41:24 EDT 2003


Hey George:

On Thu, Aug 14, 2003 at 05:48:32PM -0400, George Webb wrote:
> Hi.  I am calling @mysql_connect(...) with the leading '@' in order
> to suppress the error messages.  But then if the connect fails, I
> want to capture the exact error string of why the connect failed.
> (I.e. send it to the admin, rather than to the user.)

If you have track_errors = on you can use an approach along the lines of 
what's done in my SQL Solution class:

    $this->SQLConnection = @mysql_connect($this->SQLHost,
            $this->SQLUser, $this->SQLPassword) or die
            ( $this->KillQuery($FileName, $FileLine, $php_errormsg) );

Enjoy,

--Dan

-- 
     FREE scripts that make web and database programming easier
           http://www.analysisandsolutions.com/software/
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7th Ave #4AJ, Brooklyn NY    v: 718-854-0335   f: 718-854-0409



More information about the talk mailing list