For mysql_query, mysql_fetch_array etc I can just use false, but this doesn't work for mysql_error and mysql_errno.
Example:
Code: Select all
function GetMyGold( $connection=false )
{
return mysql_query( "SELECT gold FROM rainbow WHERE leprechaun_name='Sniffles'" , $connection );
}
$myConnection = mysql_connect(...);
mysql_select_db ("Leprechauns" , $myConnection ); // $myConnection can be omitted here
GetMyGold($myConnection); // works fine
GetMyGold(); // also works fineCode: Select all
function ShowError( $connection=false )
{
$error = mysql_error( $connection );
print("Uh oh, something bad happened: $error");
}
ShowError($myConnection); // works fine
ShowError(); // does NOT work!I can overcome that by doing (in ShowError) $error = $connection ? mysql_error($connection) : mysql_error();
My question: what can I specify as link_identifier argument to make it use the last connection? (besides not specifying it at all)
I've tried false, 0, '' (empty string), null, an unset()'ed variable, but it all results in the error above. It's not a big problem as I have a workaround, but just wondering.