A slight encapsulation of the PHP mysql_query function. I used to add this line to all my scripts:
$_sqlr = mysql_query($SQL['select']) or trigger_error('MySQL error number '.mysql_errno().': '.mysql_error(), E_USER_WARNING);
Now I use this:
// AMVC_mysql_query
/*____________________________________________________________________________*/
function AMVC_mysql_query($query)
{
// *** DATA
# internal
$_err_num = 0;
$_err_exp = '';
$_err_msg = '';
# return
$resource = FALSE;
// *** MANIPULATE
# run query
$resource = mysql_query($query);
# check result
if ( !$resource )
{
$_err_num = mysql_errno();
$_err_exp = mysql_error();
$_err_msg = "MySQL error number $_err_num : $_err_exp <br /> query: $query";
trigger_error($_err_msg, E_USER_WARNING);
}
// *** RETURN
return $resource;
} # end Fx
/*____________________________________________________________________________*/
A little more descriptive when things don't go as planned.
keywords: php, mysql, fx, query