# OOPHP + Relational MySQL DB

**URL:** <https://forum.kirupa.com/t/oophp-relational-mysql-db/215237>\
**Category:** programming\
**Created:** [February 5, 2007, 5:52pm UTC](https://forum.kirupa.com/t/oophp-relational-mysql-db/215237 "2007-02-05T17:52:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![evildrummer](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/evildrummer/32/2308_2.png) [@evildrummer](https://forum.kirupa.com/u/evildrummer)\
**Post date:** [February 5, 2007, 5:52pm UTC](https://forum.kirupa.com/t/oophp-relational-mysql-db/215237/1 "2007-02-05T17:52:42Z")

</div>

ok so I am trying to follow the two tutorials by BWH2 (hes best bet at helping) and have got this so far as my php code, I have changed some stuff from both tutorials though:

```php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PHP Files and Projects</title>
</head>

<body>
<?php
mysql_connect($_ENV['DATABASE_SERVER'], 'username', 'password');
mysql_select_db('database');
$query = "SELECT * FROM tbl_works";
$result = mysql_query($query);
$num = mysql_num_rows($result);
if (!$result) {
$message = 'Invalid query: ' . mysql_error() . "
";
$message .= 'Whole query: ' . $query;
die($message);
}
$ids = array();
$i=0;
while ($i < $num) {
$work_id=mysql_result($result,$i,'work_id');
array_push($ids, $work_id);
$i++;
}

foreach ($ids as $newid) {
$$newid = new project($newid);
}
mysql_free_result($result);
echo $1->getID();
class project {
    private $id;
    private $title;
    private $description;
    private $category;
    private $imageurl;
    function setID($val) {
        $this->id = $val;
        return;
    }
    function getID() {
        return $this->id;
    }
    function getTitle() {
        return $this->title;
    }
    function __construct($val) {
        $this->id = $val;
    }
}
mysql_close();
?>
</body>
</html>

```

But everytime I run that I get:

> 

**Parse error** : syntax error, unexpected T\_LNUMBER, expecting T\_VARIABLE or ‘$’ in **/home/5900/domains/php.digitalcarnival.com/html/index.php** on line \*\*32

\*\*P.S. I have changed my password, username and database but they are correct
