Jump to content


SOLVED - Help with PHP Class


  • You cannot reply to this topic
No replies to this topic

#1 Killswitch

    Young Padawan

  • Members
  • Pip
  • 20 posts

Posted 21 December 2007 - 12:02 AM

Edit - I am such an idiot. I knew all should work. Turns out there is no record for the secid I am trying to get :D

I have written a very small class that I am having problems with. I know the solution is probably infront of my face and an easy fix, but it's really giving me grief.

Class file
class section {
 
 var $secid;
 
	  /**
	   * Constructor
	   **/
 
	  function section($secid){
		 $this->secid = $secid;
	  }
	
	  /**
	   * Get section information
	   **/
	  
	   function getSection(){ 
		  $query = "SELECT secid, secname FROM sections"
		  . "\n WHERE secid = " .$this->secid;
		 
		   $result = mysql_query($query) or die(mysql_error());
	  $row = mysql_fetch_array($result);
	  
	  $secname = $row['secname'];	
		  return $secname;
	  }
 
	  /**
	   * Writes breadcrumb
	   **/
	   function breadcrumb(){
		  $breadcrumb = '<div id="bc">' .__SECMAN__. ' &raquo; ' .$this->getSection(). '</div>';
		  echo $breadcrumb;
	   }
 
 } // Close class

The file calling the class (the class file is called before all functions), this is snippet instatializing the class)...
function delete_section(){
 
	  if ($_GET['secid']){
		  
		 $secid = trim((int)$_GET['secid']);
 
		 // Instatiate our section class
		 $section = &new section($secid);
 
	 printf($section->breadcrumb());
	 printf($secid);
 }

I used printf($secid) to make sure there was something there, and it prints '1'. The breadcrumb prints the constant but nothing using the $secid variable. I've tried setting the var $secid in teh class manually to 1 and still no success. Any help or suggestions?

Edit - Ive even added printf to the $query in the getSection function of the class, and it prints correctly with 1 as the value.

Edited by Killswitch, 21 December 2007 - 12:36 AM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users