Questa è la pagina di connessione
Codice PHP:
$database = 'MySQL';
class sql {
var $dbl;
var $debug;
var $num_queries;
var $queries;
function connect ($host, $user, $password, $database, $debug = 0) {
$this->dbl = mysql_connect($host, $user, $password) ;
$db = mysql_select_db($database, $this->dbl);
$this->num_queries = 0;
$this->debug = $debug ? 1 : 0;
$this->queries = array();
return $db;
}
function query($query, $file, $line) {
global $queries;
if ($this->debug) { array_push($this->queries, $query); }
$result = mysql_query($query) or $this->error($file, $line);
$this->num_queries++;
return $result;
}
// Executes a normal query and fetches the array in one line
function fetch($query, $file, $line) {
$result = $this->query($query, $file, $line);
return $this->fetch_array($result);
}
function select_limit($query, $num, $offset, $file, $line) {
if ($offset) { $limit = ' LIMIT '.$offset.','.$num; }
else { $limit = ' LIMIT '.$num; }
return $this->query($query.$limit, $file, $line);
}
function fetch_array($result) {
return mysql_fetch_array($result);
}
function num_rows($result) {
return mysql_num_rows($result);
}
function escape($value, $no_html = 0) {
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
$value = mysql_real_escape_string($value, $this->dbl);
if ($no_html) {
$value = strip_tags($value);
}
return $value;
}
function error($file, $line) {
trigger_error('Database error in "'.$file.'" on line '.$line.'<br /><br />'."\n".@mysql_error($this->dbl), E_USER_ERROR);
}
function close() {
mysql_close($this->dbl);
}
}
?>
FunCool: Ricordati di usare i tag del forum per scrivere dei pezzi di codice.