Hi,
I cannot find the solution for this example. It is to do with Static declerations. Help please.
Error : "Fatal error: Non-static method ExecuteSql::executeSql() cannot be called statically, assuming $this from incompatible context "
Thanks
<?php
class DBconnection {
private $host="localhost";
private $user="root";
private $username=null;
private $password=null;
private $database="classTest";
protected $conn;
private $db;
public function __construct() {
$this->conn=mysql_connect($this->host, $this->user, $this->username, $this->password);
$this->db=mysql_select_db($this->database);
}
}
class ExecuteSql extends DBconnection {
public function executeSql($sql) {
$runSql=mysql_query($sql, DBconnection::conn) or die ("ERROR: Database connection error");
if (@mysql_num_rows($runSql) == 1) {
return "VALID";
} else {
return "INVALID";
}
}
}
class Login extends DBconnection {
public function __construct($username, $password) {
DBconnection::__construct();
echo ExecuteSql::executeSql("SELECT id FROM login WHERE username='$username' AND password='$password'");
}
}
?>
<?php
require_once("login.class.php");
$result = new Login("meme", "meme");
?>