Hallo zusammen
Hab da ein Problem mit PDO in einer PHP Klasse. Folgender Fehler:
[MAN]
Fatal error: Call to a member function prepare() on a non-object in /home/httpd/httpsdocs/libs/php/classes/connectSSD.class.php on line 30
[/MAN]
Hier die Seite welche aufgerufen wird:
So sieht die Klasse aus:
Bin ich falsch wenn ich sage dass $this->ssd ein Objekt innerhalb der Klasse der PDO klasse ist?
Gruss
Hab da ein Problem mit PDO in einer PHP Klasse. Folgender Fehler:
[MAN]
Fatal error: Call to a member function prepare() on a non-object in /home/httpd/httpsdocs/libs/php/classes/connectSSD.class.php on line 30
[/MAN]
Hier die Seite welche aufgerufen wird:
PHP-Code:
require_once 'libs/php/classes/connectSSD.class.php';
require_once 'libs/php/classes/urlworker.class.php';
require_once 'libs/php/classes/verifyClient.class.php';
// Establish connection to the SSD
$SSD = new connectSSD();
// Extract the subdomain from URL
$client = new verifyClient();
$subdomain = $client->getClient();
// Check if exists
$SSD->checkSubdomain($subdomain);
PHP-Code:
class connectSSD {
public $ssd;
function __construct(){
$DSN = "mysql:host=localhost;dbname=server1";
$NW_SSD_USER = "admin";
$NW_SSD_PASSWD = "********";
try {
$ssd = new PDO($DSN,$NW_SSD_USER,$NW_SSD_PASSWD);
}
catch (PDOException $p)
{
echo "Connection to the system failed.";
}
}
function checkSubdomain($subdomain){
$sql = $this->ssd->prepare("Select CNB from customer_index WHERE CSD =
:subdomain");
$sql->bindParam(':subdomain',$subdomain,PDO::PARAM_STR);
$sql->execute($sql);
}
}
Gruss
Kommentar