<?php //db_class.php
error_reporting(E_ALL);
class Db_Connect {
var $host; var $user; var $pasw; var $MYSQL_ERRNO; var $MYSQL_ERROR; var $query;
function make_connect($host, $user, $pasw) {
$this->host = $host; $this->user = $user; $this->pasw = $pasw;
$link_id = mysql_connect($this->host, $this->user, $this->pasw);
if (!$link_id) {
die("Impossibile connettersi al server mysql " . "<br>" .
"Dettagli: " . $this->MYSQL_ERROR . "Errore No: " . $this->MYSQL_ERRNO);
}
else {
return $link_id;
}
}
function select_db($db_name) {
if (!(mysql_select_db($db_name))) {
die("Impossibile selezionare il database " . $db_name . "<br>" .
"Dettagli: " . $this->MYSQL_ERROR . "<br>" . "Errore No: " . $this->MYSQL_ERRNO);
}
}
function sql_query($query) {
if (!(mysql_query($query))) {
die("Impossibile eseguire query al database " . "<br>" .
"Dettagli: " . $this->MYSQL_ERROR . "<br>" . "Errore No: " . $this->MYSQL_ERRNO);
}
else $result = mysql_query($query);
return $result; }
function close_connection() {
mysql_close($this->make_connect()); } }
class Result_Db extends Db_Connect {
function get_data() {
$res = $this->sql_query($query);
while($db_data = mysql_fetch_array($res)) {
echo $db_data["tot"] . "<br>";
} } }
$obj = new Result_Db; $obj->make_connect('localhost', 'root', ''); $obj->select_db('sottilelinearossa'); $obj->sql_query('select count(id) as tot from articoli'); $obj->get_data();
?>
I get this message because the variable is not valid when call the method sql_query in
the child class Result_Db.
How to fix this problem ?
Notice: Undefined variable: query in c:\programmi\apache group\apache\users\kioto\db_class2.php on line 66
Impossibile eseguire query al database
Dettagli:
Errore No:
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php