Code: Select all
class MySQL {
var $link_id;
var $Result;
var $Record = array();
var $query;
function __construct() {
$this->link_id = mysqli_connect("localhost", "", "") or $this->Error('Not connecting to the database');
$this->db = mysqli_select_db($this->link_id,'share') or $this->Error(mysqli_error());
return true;
}
function Query($sql)
{
[b] $this->Result = mysqli_query($this->link_id,$sql);[/b]
$this->query = $sql;
#print $sql;
return $this->Result;
}
function FetchArray() {
[b] $this->Record = mysqli_fetch_array($this->Result,MYSQLI_ASSOC);[/b]
return $this->Record;
}
function FetchRow() {
$this->Record = mysqli_fetch_row($this->Result) or $this->Error(mysqli_error());
return $this->Record;
}
function NumRows() {
$this->Record = mysqli_num_rows($this->Result);
return $this->Record;
}
}
class share extends MySQL {
var $row;
function __construct() {
$this->db = new MySQL();
}
function feed($user_id,$returnnum) {
$this->query("SELECT * FROM feed WHERE user_id = $user_id");
$this->FetchArray($this->query);
[b]$this->row($this->FetchArray);[/b]
$this->message = substr($this->row['message'],0,180);
return $this->message;
}
}
Errors:
Warning: mysqli_query() expects parameter 1 to be mysqli, null given on line 20
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given ion line 28
Fatal error: Call to undefined method share::row() on line 63
The lines to the respective code are bolded in the code.
Thanks,