extra curly bracket error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

extra curly bracket error

Post by afbase »

Parse error: syntax error, unexpected '{' in /home/clinton/hdd1/owl/project/project/stock/tests/stock_class.php on line 238
I can't seem to find a curly bracket error in my function that this error is referring to.

Code: Select all

function mysql_score(){
if( preg_match("!\d*.\d+!", $this->future_5_earnings[1]) && preg_match("!\d*.\d+!", $this->past_5_earnings[1])){
	$earnings = $this->future_5_earnings[1]*$this->past_5_earnings[1];
}
else{
	print  $this->ticker."doesn't have good earnings";
}


if( preg_match("!\d*.\d+!", $this->liabilities[1]) && preg_match("!!",$this->curass[1])){
	$finance = $this->curass[1] / $this->liabilities[1];
}
else{
	print $this->ticker."doesn't have liabilities or assets";
}


if( preg_match("!\d*.\d+!", $this->multiplier[1]) && preg_match("!\d*.\d+!", $this->bookval[1]){
	$pe = $this->multiplier[1] * $this->bookval[1];
	$inv_pe = 1 / $this->multiplier[1];
	$final_pe = $pe / $inv_pe;
}
else{
	print $this->ticker."needs a p/e or bookval";
}


$this->score = $earnings * $finance * $final_pe;
}
The error is referring to this particular line of code :
if( preg_match("!\d*.\d+!", $this->multiplier[1]) && preg_match("!\d*.\d+!", $this->bookval[1]){


does anybody see any problems with this class method???
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Inline error checking and bracket matching are useful in IDE's.. I personally use Zend IDE nowadays..

Code: Select all

if( preg_match("!\d*.\d+!", $this->multiplier[1]) && preg_match("!\d*.\d+!", $this->bookval[1]){
Your not missing a curly bracket, the error states it ran into one unexpectantly. Your missing a ) in there, I'll let you figure out where :)
afbase
Forum Contributor
Posts: 113
Joined: Tue Aug 15, 2006 1:29 pm
Location: SoCAL!!!!

Post by afbase »

haha thanks
Post Reply