Hallo Brotfische,
wie das Thread-Titel schon sagt, wird ein White-Screen angezeigt sobald die Function $this->_readCountyByPlace() mit aufgerufen wird.
Das System ist die erste Version einer neuen GEO-API von mir.
Kompletter Script:
PHP
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
class GeoApi
{
private $db;
private $get_plz = NULL;
private $get_debug = NULL;
private $get_city_id = NULL;
private $city_id;
private $state_id; //Bundesland
private $county_id; //Kreis
private $lat;
private $lng;
private $plz_exist;
private $o_place;
private $state;
private $county;
function __construct()
{
require_once 'system/classes/db.class.php';
$this->db = new Database;
}
public function input ($get)
{
$this->get_plz = (isset($get['plz'])) ? $get['plz'] : NULL;
$this->get_debug = (isset($get['debug'])) ? $get['debug'] : NULL;
$this->get_city_id = (isset($get['city_id'])) ? $get['city_id'] : NULL;
$this->_readCityByZip();
$this->placeByCityId();
$this->_readStateByPlace();
$this->_readCountyByPlace(); // <== Das ist mein Problemkind!
if($this->get_debug!=NULL) {
if($this->get_plz!=NULL) {
return $this->DebugPLZ();
} elseif($this->get_city_id!=NULL) {
return $this->DebugCity_id();
}
}elseif($this->get_plz!=NULL&&$this->plz_exist==FALSE) {
$array = array("error" => "Die Postleitzahl $this->get_plz existiert nicht");
} else {
$array = array(
"zipcode" => $this->get_plz,
"place" => $this->o_place,
"state" => $this->state,
"county" => $this->county,
"lat" => $this->lat,
"lng" => $this->lng);
}
return json_encode($array);
}
function placeByCityId()
{
try {
$this->db->Query("SELECT * FROM `city` WHERE `id`=:id");
$this->db->bind(':id', $this->city_id);
$this->db->execute();
} catch(PDOException $e) {
die($e->getMessage());
}
$this->o_place = ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->name;
$this->state_id = ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->state_id;
$this->county_id = ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->county_id;
//$this->county_id ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->county_id;
//$this->lat ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->lat;
//$this->lng ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->lng;
//$this->state_id ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->state_id;
}
function _readStateByPlace()
{
if($this->state_id==NULL) {
return false;
} else {
try {
$this->db->Query("SELECT * FROM `state` WHERE `id`=:state");
$this->db->bind(':state', $this->state_id);
$this->db->execute();
} catch(PDOException $e) {
die($e->getMessage());
}
$this->state = ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->name;
}
}
function _readCountyByPlace()
{
if($this->county_id==NULL) {
return false;
} else {
try {
$this->db->Query("SELECT * FROM `county` WHERE `id`=:county");
$this->db->bind(':county', $this->county_id);
$this->db->execute();
}catch(PDOException $e) {
die($e->getMessage());
}
//if($this->db->rowCount()==0) {die('failed');} else(die('okay'));
$this->county = ($this->db->rowCount()==0) ? NULL : $this->db->fetch()->name;
}
}
function _readCityByZip()
{
if($this->get_plz==NULL) {
return false;
} else {
try {
$this->db->Query("SELECT * FROM `zipcode` WHERE `zipcode`=:plz");
$this->db->bind(':plz', $this->get_plz);
$this->db->execute();
}catch(PDOException $e) {
die($e->getMessage());
}
$this->plz_exist = ($this->db->rowCount()==0) ? FALSE : TRUE;
$this->city_id = ($this->db->rowCount()==0) ? 'NULL' : $this->db->fetch()->city_id;
}
}
function DebugPLZ()
{
if($this->get_plz=="") {
$r = array("error" => "Keine Postleitzahl angegeben");
} else {
try
{
$this->db->Query("SELECT * FROM `zipcode` WHERE `zipcode`=:plz");
$this->db->bind(':plz', $this->get_plz);
$this->db->execute();
$r = $this->db->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $e) {
$r = array("error" => $e->getMessage());
}
}
return json_encode($r);
}
function DebugCity_id()
{
if($this->get_city_id=="") {
$r = array("error" => "Keine City_id angegeben");
} else {
try
{
$this->db->Query("SELECT * FROM `city` WHERE `id`=:cityid");
$this->db->bind(':cityid', $this->get_city_id);
$this->db->execute();
$r = ($this->db->rowCount()==0) ? array("error" => "Die City_id $this->get_city_id existiert nicht") : $this->db->fetch(PDO::FETCH_ASSOC);
} catch(PDOException $e) {
$r = array("error" => $e->getMessage());
}
}
return json_encode($r);
}
}
?>
Alles anzeigen
function input wird letztendlich dann in der Index-Datei ausgeführt.
Sobald die function $this->_readCountyByPlace() in der input() auskommentiert wird, funktioniert alles einwandfrei. Ich kann mir den Fehler nicht erklären.
Sofern ich mit die() or echo eine Ausgabe in _readCountyByPlace() erzwinge, wird trotzdem alles andere nicht angezeigt.
Vielleicht habt ihr Fehlerbehebungslösungen die mir weiterhelfen....