/**
* Escapes data when going into the database.
* This is not for SQL Injections.
**/
function escape($value)
{
if (!is_int($value))
{
if (is_numeric($value))
{
$value = floatval($value);
}
else
{
$value = (get_magic_quotes_gpc()) ? $value : addslashes($value);
}
$value = "'" . $value . "'";
}
return $value;
}
/**
* Checks how many rows were found from a query.
**/
function num_rows($resource)
{
return mysql_num_rows($resource);
}
/**
* Insert data into the database.
* Generates query based on $data array (field => val)
**/
function insert($table, $data)
{
// Field Names
$columnbit = '';
$columns = array_keys($data);
for ($i=0; $i<count($columns); $i++)
{
$columnbit .= (($i) ? ', ' : '') . '`' . $columns[$i] . '`';
}