0 ) ) { return mysql_result( $p_result, $p_index1, $p_index2 ); } else { return false; } } # -------------------- # return the last inserted id function db_insert_id() { if ( mysql_affected_rows() > 0 ) { return mysql_insert_id(); } else { return false; } } ### -------------------- function db_close() { $t_result = mysql_close(); } ### -------------------- # -------------------- # prepare a string before DB insertion function db_prepare_string( $p_string ) { return mysql_escape_string( $p_string ); } # -------------------- # prepare an integer before DB insertion function db_prepare_int( $p_int ) { return (integer)$p_int; } # -------------------- # prepare a boolean before DB insertion function db_prepare_bool( $p_bool ) { return (int)(bool)$p_bool; } # -------------------- # generic unprepare if type is unknown function db_unprepare( $p_string ) { return stripslashes( $p_string ); } # -------------------- # unprepare a string after taking it out of the DB function db_unprepare_string( $p_string ) { return db_unprepare( $p_string ); } # -------------------- # unprepare an integer after taking it out of the DB function db_unprepare_int( $p_int ) { return (integer)db_unprepare( $p_int ); } # -------------------- # unprepare a boolean after taking it out of the DB function db_unprepare_bool( $p_bool ) { return (bool)db_unprepare( $p_bool ); } # -------------------- # calls db_unprepare() on every item in a row function db_unprepare_row( $p_row ) { if ( false == $p_row ) { return false; } $t_new_row = array(); while ( list( $t_key, $t_val ) = each( $p_row ) ) { $t_new_row[$t_key] = db_unprepare( $t_val ); } return $t_new_row; } ########################################################################### ### CODE TO EXECUTE ### ########################################################################### db_connect( $g_hostname, $g_db_username, $g_db_password, $g_database_name ); ?>