Jump to content


Photo

parse error, unexpected T_DOUBLE_ARROW


  • Please log in to reply
3 replies to this topic

#1 bassplaya4string

bassplaya4string
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 26 October 2006 - 04:13 AM

anybody see anything wrong with this code?

if ($score < 3){
$image1 = "<img src = 'images/0-3.jpg'>";
}
else ($score => 4 && =< 7){
$image2 = "<img src = 'images/4-7.jpg'>";
}
else ($score => 8 && =< 10){
$image3 = "<img src = 'images/8-10.jpg'>";
}


#2 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 26 October 2006 - 04:17 AM

PHP uses >= instead of =>, because => has another meaning.

if ($a >= 5) { $arr = array('fred' => 5); }


#3 bassplaya4string

bassplaya4string
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 26 October 2006 - 04:30 AM

I switched them but it came back with this error now

parse error, unexpected T_IS_SMALLER_OR_EQUAL

if ($score <= 3){
$image1 = "<img src = 'images/0-3.jpg'>";
}
else if ($score >= 4 && <= 7){
$image2 = "<img src = 'images/4-7.jpg'>";
}
else ($score >= 8 && <= 10){
$image3 = "<img src = 'images/8-10.jpg'>";
}
}
}


#4 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 26 October 2006 - 06:19 AM

if ($score <= 3){
$image1 = "<img src = 'images/0-3.jpg'>";
}
else if (($score >= 4) && ($score <= 7)){
$image2 = "<img src = 'images/4-7.jpg'>";
}
else (($score >= 8) && ($score <= 10)){
$image3 = "<img src = 'images/8-10.jpg'>";
}

or...

switch ($score) {
   case >= 8 : $image3 = "<img src = 'images/8-10.jpg'>"; break;
   case >= 4 : $image2 = "<img src = 'images/4-7.jpg'>"; break;
   case <= 3 : $image1 = "<img src = 'images/0-3.jpg'>"; break;
}

although i'm not sure i understand your logic here.. I mean, you have 3 different variables (image1,image2, image3) and depending on what score is, one of those 3 get changed.  Are you going to later on check which one exists or something? I suppose that's all up to you on what you're doing.  It just seemed odd to me..
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users