\n".$sql_string); //mysql_db_query returns 1 on a insert statement -> no need to ask for results if ($result != 1) { for($i=0; $i< mysql_num_rows($result); $i++) { $temparray = mysql_fetch_assoc($result); $resultarray[]=$temparray; } mysql_free_result ($result); }elseif($result == 1 && mysql_insert_id($link)) { $resultarray = mysql_insert_id($link); //give back ID on insert } return $resultarray; } /** * Build an string of URL parameters * * Handles URL encoding */ function buildURLparams($params,$sep='&'){ $url = ''; $amp = false; foreach($params as $key => $val){ if($amp) $url .= $sep; $url .= $key.'='; $url .= urlencode($val); $amp = true; } return $url; } /** * Build an string of html tag attributes * * Handles html encoding */ function buildAttributes($params){ $url = ''; foreach($params as $key => $val){ $url .= $key.'="'; $url .= htmlspecialchars ($val); $url .= '" '; } return $url; } /** * Helper to print a variable's content - just for debugging */ function dbg($val){ print '
';
    print_r($val);
    print '
'; } // http://www.php.net/manual/en/function.html-entity-decode.php function unhtmlentities($string){ // replace numeric entities $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); // replace literal entities $trans_tbl = get_html_translation_table(HTML_ENTITIES); $trans_tbl = array_flip($trans_tbl); $trans_tbl['''] = "'"; return strtr($string, $trans_tbl); } /** * print a message * * If HTTP headers were not sent yet the message is added * to the global message array else it's printed directly * using html_msgarea() * * * Levels can be: * * -1 error * 0 info * 1 success * * @author Andreas Gohr * @see html_msgarea */ function msg($message,$lvl=0){ global $MSG; $errors[-1] = 'error'; $errors[0] = 'info'; $errors[1] = 'success'; if(!headers_sent()){ if(!isset($MSG)) $MSG = array(); $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); }else{ $MSG = array(); $MSG[]=array('lvl' => $errors[$lvl], 'msg' => $message); if(function_exists('html_msgarea')){ html_msgarea(); }else{ print "ERROR($lvl) $message"; } } } //Setup VIM: ex: et ts=4 enc=utf-8 :