OOP Problem with getting data

PythonPython Forum LeaderThe Royal RAM
I have the following code:

[PHP]<?php
// Database Class
class mysql
{
private $linkid;
private $host;
private $user;
private $password;
private $database;
private $result;


// Class constructer
function __construct($host, $user, $password, $database)
{
$this->host = $host;
$this->user = $user;
$this->password = $password;
$this->database = $database;
}

// Connect to database
function connect()
{
$this->linkid = @mysql_connect($this->;host,$this->user,$this->password);
if(!$this->linkid)
{
die("Could not connect to the MySQL server");
}
}

// Select the database
function select()
{
if(!@mysql_select_db($this->;database,$this->linkid))
{
die("Could not select database");
}
}

// Query the database
function query()
{
$this->result = mysql_query($query);
return $this->result;
}

// Affected rows
function affectedrows()
{
$count = @mysql_affected_rows($this->;linkid);
return $count;
}

// Return query as an object
function fetchobject()
{
$row = @mysql_fetch_object($this->;result);
return $row;
}

// Return query as an associative array
function fetcharray()
{
$row = @mysql_fetch_array($this->;result);
return $row;
}

} // end mysql class


// Create new MySQL object
$mysqldb = new mysql("localhost","X","X","X");

// Connect and selectd database
$mysqldb->connect();
$mysqldb->select();

$mysqldb->query("SELECT * FROM `board1_forums`");
while($data = $mysqldb->fetchobject())
{
echo $data->name;
}

?>[/PHP]

Obviously in mine the database connection info is right ;)

But basically when I run that script nothing is displayed. It is supposed to loop around and display the value in the column name from a table.

But its blank...

Any ideas? Thanks

The Royal Ram

Comments

  • PythonPython Forum Leader The Royal RAM
    Problem solved :D

    I forgot to put $query into the function when setting it ;)

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    thats for phpboard isnt it!
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    nope... phpboard has been pushed towards the end of my project list for now...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    really...interesting
    ban1.gif
Sign In or Register to comment.