> If says: > > Returns the escaped string, or FALSE on error. > > So all you have to do, is have warnings turned off (as it generates an > E_WARNING if you have no active connection) and then look at the return > value of a call to the function: > > if(mysql_real_escape_string($variable) === false) > { > // create a default DB connection > } I would rather suggest: $error_reporting = error_reporting(0); if(mysql_real_escape_string($variable) === false) { // create a default DB connection } error_reporting($error_reporting); unset($error_reporting); _________________________________________________________________ Windows Live: Keep your friends up to date with what you do online. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010