chriscloyd Posted January 26, 2007 Share Posted January 26, 2007 heres the error im gettingParse 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 4heres my code[code]<?phpclass 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] Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/ Share on other sites More sharing options...
jumpenjuhosaphat Posted January 26, 2007 Share Posted January 26, 2007 On line 4, replace [code]private $id;[/code]with[code]private($id);[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169542 Share on other sites More sharing options...
hvle Posted January 26, 2007 Share Posted January 26, 2007 Your code is good, however your PHP version is not.Make sure whichever server running this class is using PHP 5.0 or later.PHP 4.x won't understand this class. Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169552 Share on other sites More sharing options...
chriscloyd Posted January 26, 2007 Author Share Posted January 26, 2007 how do i find out if its php 5 Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169577 Share on other sites More sharing options...
hvle Posted January 26, 2007 Share Posted January 26, 2007 you can upload a file with this content to the server:[code]<?phpphpinfo();?>[/code]Access that page and you will see all phpinfo. Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169623 Share on other sites More sharing options...
wildteen88 Posted January 26, 2007 Share Posted January 26, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/35773-php-class/#findComment-169918 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.