Note that there are some explanatory texts on larger screens.

plurals
  1. POphp class not responding
    primarykey
    data
    text
    <p>I have a problem with the following piece of PHP script:</p> <pre><code>&lt;?php abstract class root { protected $con; protected $sql; protected $query; protected $row; protected function __construct__() { require_once("db.settings.php"); $this-&gt;con = mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error($this-&gt;con)); mysql_query("SET NAMES UTF8", $this-&gt;con) or die(mysql_error($this-&gt;con)); mysql_close($this-&gt;con); mysql_select_db(DB_NAME, $this-&gt;con); } protected function __destruct__() { mysql_close($this-&gt;con); unset($this-&gt;con); } } class users extends root { private $h; public function __construct__() { parent::__construct__(); } public function __destruct__() { parent::__destruct__(); } public function register($uname, $pass, $mail, $name) { $this-&gt;hash = sha1($uname . md5($pass) . $name); $this-&gt;sql = "INSERT INTO users (user, pass, mail, name, hash) VALUES ($uname, $pass, $mail, $name, $this-&gt;hash)"; mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); mysql_close($this-&gt;con); return true; } public function login($uname, $pass) { $this-&gt;sql = "SELECT * FROM users WHERE user = $uname AND pass = " . md5($pass); mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); if(mysql_num_rows !== 1){ mysql_close($this-&gt;con); return false; } else { setcookie("who", $uname, time() + 3600); $this-&gt;h = md5($pass); setcookie("token", $this-&gt;h, time() + 3600); $this-&gt;h = sha1($uname . md5($pass)); setcookie("hash", $uname, time() + 3600); return true; } } public function logout() { if(isset($_COOKIE['who']) &amp;&amp; isset($_COOKIE['token']) &amp;&amp; isset($_COOKIE['hash']) &amp;&amp; $_COOKIE['hash'] == sha1($_COOKIE['who'] . $_COOKIE['token'])) { setcookie("who", $uname, time() - 1); setcookie("token", $uname, time() - 1); setcookie("hash", $uname, time() - 1); return true; } else { setcookie("who", $uname, time() - 1); setcookie("token", $uname, time() - 1); setcookie("hash", $uname, time() - 1); return false; } } public function check() { if(isset($_COOKIE['who']) &amp;&amp; isset($_COOKIE['token']) &amp;&amp; isset($_COOKIE['hash']) &amp;&amp; $_COOKIE['hash'] == sha1($_COOKIE['who'] . $_COOKIE['token'])) { return true; } else { return false; } } } class iPhone extends root { private $hash; public $content = array(); private $j = 0; public function __construct__() { parent::__construct__(); } public function __destruct__() { parent::__destruct__(); } public function registerIphone() { # implented later $this-&gt;hash = md5(time); $this-&gt;sql = "UPDATE users SET phoneid = " . $this-&gt;hash . " WHERE user = " . $_COOKIE['who']; mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); setcookie("phoneid", $this-&gt;hash, 1314000); return true; } public function checkIphone() { # implented later $this-&gt;sql = "SELECT * FROM users WHERE phoneid = " . $_COOKIE['phoneid'] . " LIMIT 1"; if(mysql_query($this-&gt;sql, $this-&gt;con)) { return true; } else { return false; } } public function deleteIphone($who) { # implented later $this-&gt;sql = "UPDATE users SET phoneid = '' WHERE user = $who"; if(mysql_query($this-&gt;sql, $this-&gt;con)) { return true; } else { return false; } } public function showContent($what) { $this-&gt;sql = "SELECT * FROM content WHERE articleName = " . $what . " AND media = Handheld"; $this-&gt;query = mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); while($this-&gt;row = mysql_fetch_array($this-&gt;query)) { $content[$j]['id'] = $row['id']; $content[$j]['date'] = $row['date']; $content[$j]['articleName'] = $row['articleName']; $content[$j]['content'] = $row['content']; $this-&gt;j++; } mysql_close($this-&gt;con); return $this-&gt;content; } } class contentManager extends root { public $content = array(); private $j = 0; public function __construct__() { parent::__construct__(); } public function __destruct__() { parent::__destruct__(); } public function showContent($what) { $this-&gt;sql = "SELECT * FROM content WHERE articleName = $what AND media = Browser"; $this-&gt;query = mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); while($this-&gt;row = mysql_fetch_array($this-&gt;query)) { $content[$j]['id'] = $row['id']; $content[$j]['date'] = $row['date']; $content[$j]['articleName'] = $row['articleName']; $content[$j]['content'] = $row['content']; $this-&gt;j++; } mysql_close($this-&gt;con); return $this-&gt;content; } public function editContent($id, $articlename, $content) { $this-&gt;sql = "UPDATE content SET articleName = $articlename, content = $content WHERE id = $id"; mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); return true; } public function deleteContent($id) { $this-&gt;sql = "DELETE FROM content WHERE id = $id"; mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); return true; } } class map extends root { private $j = 0; private $key = "my google maps api key"; private $address; private $helper; private $page; private $xml; private $longitude; private $latitude; private $altitude; public function __construct__() { parent::__construct__(); } public function __destruct__() { parent::__destruct__(); } public function getMarkers() { $this-&gt;sql = "SELECT * FROM markers"; $this-&gt;query = mysql_query($this-&gt;sql, $this-&gt;con) or die(mysql_error($this-&gt;con)); while($this-&gt;row = mysql_fetch_array($this-&gt;query)) { if($this-&gt;j &lt; (mysql_num_rows($this-&gt;query) -1 )){ print("['" . $this-&gt;row['address'] . "', " . $this-&gt;row['lat'] . ", " . $this-&gt;row['lng'] . ", 1],"); $this-&gt;j++; } else { print("['" . $this-&gt;row['address'] . "', " . $this-&gt;row['lat'] . ", " . $this-&gt;row['lng'] . ", 1]"); $this-&gt;j++; } } } public function setMarkers($addr) { $this-&gt;helper = str_replace(" ", "+", $addr); $this-&gt;helper = explode(",", $this-&gt;helper); $this-&gt;address = "http://maps.google.com/maps/geo?q=$this-&gt;helper[0],+$this-&gt;helper[1],+$this-&gt;helper[2]&amp;output=xml&amp;key=$this-&gt;key"; $this-&gt;page = file_get_contents($this-&gt;address); $this-&gt;xml = new SimpleXMLElement($this-&gt;page); list($this-&gt;longitude, $this-&gt;latitude, $this-&gt;altitude) = explode(",", $xml-&gt;Response-&gt;Placemark-&gt;Point-&gt;coordinates); echo $this-&gt;longitude . " :: " . $this-&gt;latitude; } public function deleteMarkers($id) { /* *** FUNCTION NOT YET IMPLENTED! */ } } ?&gt; </code></pre> <p>For those, who do not want to read source: I create an abstract class, that creates database connection, then other classes, like login extends it, using the parents database connection.</p> <p>The problem is, whenever I create an instance of a class, like:</p> <pre><code>$map = new map(); </code></pre> <p>Then try to do something with the instance:</p> <pre><code>$map-&gt;setMarkers(""); </code></pre> <p>Nothing happens. Literally nothing. No error message, and no output.</p> <p>All help would be highly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload