chriscloyd Posted January 31, 2007 Share Posted January 31, 2007 Okay i have some functions in my php class but im tyring to call a function from inside my class like below but it does not work heres 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 project_screenshots 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 project_screenshots WHERE pid = '{$this->id}' AND id != '{$project->file1()}")) { if (mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); return $row['location']; } } }}?>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 too much code to look through without more info. What error do you get that makes you say it's "not working" Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted January 31, 2007 Author Share Posted January 31, 2007 Fatal error: Call to a member function file1() on a non-object in /home/srxstud/public_html/test22/includes/porfolio_getfunctions.php on line 55 Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 Okay this line:if ($result = mysql_query("SELECT `location` FROM project_screenshots WHERE pid = '{$this->id}' AND id != '{$project->file1()}")) {What is $project? Just like you use $this to reference id, a variable, you need to use it to call the methods.$this->file1() Quote Link to comment Share on other sites More sharing options...
chriscloyd Posted January 31, 2007 Author Share Posted January 31, 2007 didnt work Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 31, 2007 Share Posted January 31, 2007 [quote author=jesirose link=topic=124811.msg517694#msg517694 date=1170213728]too much code to look through without more info. What error do you get that makes you say it's "not working"[/quote]I didn't mean just that one time dude. If all you can say is "didn't work", all the help you'll get is "tough luck" Quote Link to comment 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.