Nieuw lid |
|
Dit is de error;
[31-Oct-2007 11:17:53] PHP Notice : Trying to get property of non-object in D: \webserver\LocalUser\superdumb\index.php on line 5
dit is het bestand
lib/mysql.php
<?php
class db
{
protected $connect;
protected $link;
protected $user = 'superdumb';
protected $pass = '******';
protected $server = 'localhost';
protected $query;
protected $obj;
public $output;
function __construct($db_name)
{
print ' Constructor treedt op ...';
$this->connect = mysql_connect($this->server,$this->user,$this->pass);
if(!($this->connect))
{
echo 'Geen connectie... ';
echo mysql_error();
die();
}
echo ' Connectie is er...';
$this->link = mysql_select_db($db_name,$this->connect);
if(!($this->link))
{
echo 'Database niet geselecteerd... ';
echo mysql_error();
die();
}
echo ' Database link is er...';
}
function getdata()
{
function __construct($id,$table,$what)
{
$this->query = mysql_query("SELECT ".$what." FROM ".$table." WHERE id=".$id);
if(!($this->query))
{
echo 'Query niet uitgevoerd';
echo mysql_error();
die();
}
echo ' Query uitgevoerd';
while ($this->obj = mysql_fetch_object($this->query))
{
$this->output = $this->obj->$what;
}
}
}
}
?>
<?php class db { protected $connect; protected $link; protected $user = 'superdumb'; protected $pass = '******'; protected $server = 'localhost'; protected $query; protected $obj; public $output; function __construct($db_name) { print ' Constructor treedt op ...'; $this->connect = mysql_connect($this->server,$this->user,$this->pass); if(!($this->connect)) { echo 'Geen connectie... '; } echo ' Connectie is er...'; if(!($this->link)) { echo 'Database niet geselecteerd... '; } echo ' Database link is er...'; } function getdata() { function __construct($id,$table,$what) { $this->query = mysql_query("SELECT ".$what." FROM ".$table." WHERE id=".$id); if(!($this->query)) { echo 'Query niet uitgevoerd'; } echo ' Query uitgevoerd'; { $this->output = $this->obj->$what; } } } } ?>
en dit index.php
<?php
require('lib/mysql.php');
$db1 = new db('superdumb_db');
$db1->getdata('1','tbl_users','firstname');
echo $db1->output;
?>
<?php require('lib/mysql.php'); $db1 = new db('superdumb_db'); $db1->getdata('1','tbl_users','firstname'); ?>
Dit is ongeveer hetzelfde script als gisteren, alleen hier werkt ik met een classes met daarin meedere functies....
|