Having trouble with a class

Discussion in 'PHP' started by xxKillswitch, Dec 20, 2007.

  1. #1
    Edit - I am such an idiot. Turns out there is no record for the record I am requesting :D Maybe I should have checked that earlier :p

    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
    Code (markup):
    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);
    }
    Code (markup):
    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.
     
    xxKillswitch, Dec 20, 2007 IP