_Claudio
27-04-2010, 14:09
Ciao a tutti.
Ho un problema con le classi di php.
Io ho una classe:
<?php
require_once "errormanager.php";
class Querier {
private $conn;
private $db;
function __construct($db = 'xvb') {
$this->db = $db;
$this->connect();
}
private function connect() {
$this->conn = @mysql_connect('localhost', 'lacascinarossa', 'admin');
@mysql_select_db($this->db , $this->conn);
}
function isconnected() { return @mysql_ping($this->conn); }
function doquery($query) { return @mysql_query($query, $this->conn); }
}
?>
e poi c'è un'altra classe:
<?php
require_once "querier.php";
require_once "errormanager.php";
class PhotosManager {
private $querier;
function __construct() { $this->querier = new Querier(); }
function __destruct() { $this->querier->__destruct(); }
function insert($rawimage) {
if(is_uploaded_file($rawimage['tmp_name'])) {
$imageinfo = getimagesize($rawimage['tmp_name']);
if($imageinfo[0] > 400 || $imageinfo[1] > 400) resize();
if($imageinfo['mime'] != "image/png") convert();
$imagedata = addslashes(file_get_contents($rawimage['tmp_name']));
$imagethumb = $this->createthumb($imagedata);
$querier->doquery("INSERT INTO images (ID, thumb, data, type, size) VALUES('', '{$imagethumb}', '{$imagedata}',
'{$imageinfo['mime']}', '{$imageinfo[3]}'");
} else {
print "File non specificato";
}
}
... continua
ho anche altre classi che usano la classe Querier.
Mi viene fuori l'errore:
Debug Error: /photosmanager.php line 19 - Call to a member function doquery() on a non-object
In pratica a run-time non mi vede la classe querier, eppure chiamo correttamente il costruttore.
Non capisco cosa possa essere, a volte lo fa anche con altre classi, altre volte non lo fa.
Ho un problema con le classi di php.
Io ho una classe:
<?php
require_once "errormanager.php";
class Querier {
private $conn;
private $db;
function __construct($db = 'xvb') {
$this->db = $db;
$this->connect();
}
private function connect() {
$this->conn = @mysql_connect('localhost', 'lacascinarossa', 'admin');
@mysql_select_db($this->db , $this->conn);
}
function isconnected() { return @mysql_ping($this->conn); }
function doquery($query) { return @mysql_query($query, $this->conn); }
}
?>
e poi c'è un'altra classe:
<?php
require_once "querier.php";
require_once "errormanager.php";
class PhotosManager {
private $querier;
function __construct() { $this->querier = new Querier(); }
function __destruct() { $this->querier->__destruct(); }
function insert($rawimage) {
if(is_uploaded_file($rawimage['tmp_name'])) {
$imageinfo = getimagesize($rawimage['tmp_name']);
if($imageinfo[0] > 400 || $imageinfo[1] > 400) resize();
if($imageinfo['mime'] != "image/png") convert();
$imagedata = addslashes(file_get_contents($rawimage['tmp_name']));
$imagethumb = $this->createthumb($imagedata);
$querier->doquery("INSERT INTO images (ID, thumb, data, type, size) VALUES('', '{$imagethumb}', '{$imagedata}',
'{$imageinfo['mime']}', '{$imageinfo[3]}'");
} else {
print "File non specificato";
}
}
... continua
ho anche altre classi che usano la classe Querier.
Mi viene fuori l'errore:
Debug Error: /photosmanager.php line 19 - Call to a member function doquery() on a non-object
In pratica a run-time non mi vede la classe querier, eppure chiamo correttamente il costruttore.
Non capisco cosa possa essere, a volte lo fa anche con altre classi, altre volte non lo fa.