Jump to content

php class


chriscloyd

Recommended Posts

heres the error im getting

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /home/srxstud/public_html/test22/includes/porfolio_getfunctions.php on line 4

heres my code


[code]
<?php
class getproject
{
private $id;
    function __construct() {
if (!isset($_GET['project'])) {
$get_project = mysql_query("SELECT * FROM projects ORDER BY id DESC");
$pid = mysql_fetch_assoc($get_project);
$this->id = $pid['id'];
} else {
$this->id = $_GET['project'];
}
    }
function name() {
if ($result = mysql_query("SELECT `title` FROM projects WHERE id = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['title'];
}
}
}
function type() {
if ($result = mysql_query("SELECT `type` FROM projects WHERE id = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['type'];
}
}
}
function start() {
if ($result = mysql_query("SELECT `startdate` FROM projects WHERE id = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['startdate'];
}
}
}
function enddate() {
if ($result = mysql_query("SELECT `enddate` FROM projects WHERE id = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['enddate'];
}
}
}
function file1() {
if ($result = mysql_query("SELECT `location` FROM projects_files WHERE pid = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['location'];
}
}
}
function file2() {
if ($result = mysql_query("SELECT `location` FROM projects_files WHERE pid = '{$this->id}'")) {
if (mysql_num_rows($result) > 0) {
$row = mysql_fetch_assoc($result);
return $row['location'];
}
}
}
}
?>
[/code]
Link to comment
Share on other sites

or just run this code:
[code=php:0]<?php echo 'Current PHP version: ' . phpversion(); ?>[/code]
to get the version of PHP your server is running.

However I can confirm that you probably are not running PHP5 if PHP is reporting an error on this line:
[code=php:0]private $id;[/code]


Your version is most probably PHP4. PHP4 has very low OOP support. PHP5 is the version you will want for creating OOP scripts.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.