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
https://forums.phpfreaks.com/topic/35773-php-class/
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
https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169918
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.