'.mysql_error().'
database down, please contact system administrator

'.CLIENT.''; } else { echo '



database down, please contact system administrator

'.CLIENT.'
'; } die(); } } //closes the database, while it's a function that calls out another function, it is more clear in coding //syntax if similar database commands are used in the system function dbClose(){ global $mysql_connection_key; mysql_close($mysql_connection_key); } //sends a query into database and returns an array for use //array works with two indexes, first being the row number of returned result, and the second being the column name //you can use $key to get a single column values into a one-dimensional array, instead of multiple-dimensional array function dbMatrix($query,$key='*',$debug=0){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; $output=mysql_query($query); if($output){ $i=0; while($line=mysql_fetch_array($output,MYSQL_ASSOC)){ if($key=='*'){ $result[$i]=$line; } else { $result[$i]=$line[$key]; } $i++; } if(isset($result)){ return $result; } else { if($debug==1){ echo '
';
				echo mysql_error();
				echo '
'; } return false; } } else { return false; } } //sends a query into database and returns an array for use //works as the example above, but only returns single row and skips the first index, array's only index is the column name function dbSingle($query, $debug=0){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; $output=mysql_query($query); if($output){ if($line=mysql_fetch_array($output,MYSQL_ASSOC)){ $result=$line; } if(isset($result)){ return $result; } else { if($debug==1){ echo '
';
				echo mysql_error();
				echo '
'; } return false; } } else { return false; } } //executes a specific query without returning value function dbCommand($command){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; if(!mysql_query($command)){ return false; } return true; } //count values in database function dbCount($value,$field,$table,$restriction=''){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; if($restriction==''){ $query='SELECT COUNT(*) FROM '.$table.' WHERE '.$field.'="'.$value.'";'; } else { $query='SELECT COUNT(*) FROM '.$table.' WHERE '.$field.'="'.$value.'" AND '.$restriction.';'; } $output=mysql_query($query); if($output){ if($line=mysql_fetch_array($output,MYSQL_ASSOC)){ $result=$line['COUNT(*)']; } return $result; } else { return false; } } //counts database rows in table function dbCountrows($tablename,$condition=''){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; if ($condition!=''){ $condition.=' WHERE '.$condition; } $rowcount=mysql_fetch_array(mysql_query('select COUNT(*) from '.$tablename.' '.$condition.';'),MYSQL_ASSOC); } //returns specific value from table function dbValue($targetfield, $targettable, $condition){ global $__SBQUERYCOUNTER; $__SBQUERYCOUNTER++; $query=dbSingle('SELECT '.mysql_real_escape_string($targetfield).' FROM '.mysql_real_escape_string($targettable).' WHERE '.mysql_real_escape_string($condition).' LIMIT 1;'); return $query[$targetfield]; } ?>