Jump to content

[SOLVED] Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ')'


ballhogjoni

Recommended Posts

Don't know why this is happening. Can someone helpme figure this one out? The error is on line 12, here is the line of code:

 

function Select($this->sTable="",$a_sData="",$sWhere="",$sGroupBy=""){

 

All my code:

class FACSDatabase {
function FACSDatabase($sTable=""){
	$this->sTable = $sTable;
}

function Select($this->sTable="",$a_sData="",$sWhere="",$sGroupBy=""){
	if( is_array( $a_sData ) ){
		$a_sData = ""
		foreach( $a_sData as $data => $value ){
			$a_sData .= $value;
		}
		$aResult = mysql_query("SELECT ".$a_sData." FROM ".$this->sTable." ".$sWhere." ".$sGroupBy);
	}else{
		$aResult = mysql_query("SELECT ".$a_sData." FROM ".$this->sTable." ".$sWhere." ".$sGroupBy);
	}
	return $aResult;
}
}

 

I am using PHP 5.2.6

 

Thanks

You can't do that in a function header because $this->sTable is NOT being passed into the function.  Try something like:

 

function Select($sTable=null,$a_sData=null,$sWhere=null,$sGroupBy=null){

  if (!$sTable) {

        $sTable = $this->sTable;

  }

  //rest of code

}

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.