如果PHP中的语句结构

I keep getting an error with the following bit of code. It is probably some small thing but I don't see what is wrong.

while($row = mysql_fetch_array($result))
  {
   $varp = $row['ustk_retail'];
   if ($varp<80000) { $o1 = 1; }
   if (($varp=>80000) && ($varp<100000)) { $o2 = "1"; }
   if (($varp=>100000) && ($varp<120000)) { $o3 = "1"; }
   if (($varp=>120000) && ($varp<140000)) { $o4 = "1"; }
   if (($varp=>140000) && ($varp<160000)) { $o5 = "1"; }
   if (($varp=>160000) && ($varp<180000)) { $o6 = "1"; }
   if (($varp=>180000) && ($varp<200000)) { $o7 = "1"; }
   if (($varp=>200000) && ($varp<220000)) { $o8 = "1"; }
   if (($varp=>220000) && ($varp<240000)) { $o9 = "1"; }
   if (($varp=>240000) && ($varp<260000)) { $o10 = "1"; }
   if (($varp=>260000) && ($varp<280000)) { $o11 = "1"; }
   if (($varp=>280000) && ($varp<300000)) { $o12 = "1"; }
   if ($varp>=300000) { $o13 = "1"; }
  }

Greater than or equal to is >= sign, not =>

Update:
You are right. It's small but hard to find mistake.
It took me to split whole line into pieces to see where the problem is:

<?php
if 
(
$varp
=>
80000
)

So, it says parse error on line 5 and I had to doublecheck this operator.
Of course, at first I separated the problem line from the rest of the code to be certain.

Running php -l (lint) on your code I get a

Parse error: syntax error, unexpected T_DOUBLE_ARROW

The T_DOUBLE_ARROW token is what PHP expects when assigning array values to array keys.

When comparing for Greater than or equal to the PHP Parser expects T_IS_GREATER_OR_EQUAL, meaning you have to use >= instead of =>.

See

Add one more bracket around the conditions in if....

if ( ($varp80000) && ($varp100000) && ($varp120000) && ($varp140000) && ($varp160000) && ($varp180000) && ($varp200000) && ($varp220000) && ($varp240000) && ($varp260000) && ($varp280000) && ($varp=300000) ) { $o13 = "1"; }

You probably want to change ($varp=300000) to ($varp==300000) and it might help to enclose the full if-statement inside (), like this

if($varp80000 && $varp100000 && $varp120000 && $varp140000 && $varp160000 && $varp180000 && $varp200000 && $varp220000 && $varp240000 && $varp260000 && $varp280000 && $varp==300000) { $o13 = "1"; }

On another note, where to these strange $varp#### variables come from?

Not sure whether the code you've posted has gotten messed up somehow, but it looks like you're missing "==" in some of the if conditions. Also, as Skilldrick pointed out, the whole if condition should be in parentheses

This is more readable and compact way to do the same:

$ranges = range(300000, 80000, -20000);

$index = 1;

$varp = 220001;

foreach ($ranges as $i => $range) {
    if ($varp >= $range) {
        $index = 13 - $i;
        break;
    }
}

${'o' . $index} = 1;

Anyway - I think you're doing something wrong with using variable name of result.

You have an expression error.

$varp=>220000 // is not a valid php expression

=> operator is used to assign values in arrays like:

$x = array( 'foo' => 'bar');

>= is the comparation assigment greater than or equal

The answer has already been given but thought this was neat enough to share:

PHP accepts boolean expressions in it's switch statement.

switch(TRUE) {
    case $range <= 10:  echo "range below or equal to 10"; break;
    case $range <= 20:  echo "range above 10 below or equal to 20"; break;
    case $range <= 30:  echo "range above 20 below or equal to 30"; break;
    default: echo "high range";
}

In my opinion this generates the cleanest most readable code.

You have made a mistake in the if conditions. The greater than Equal to sign is >= and not =>.

"Greater than or equal to is >= NOT =>. You use => for arrays for keys/values.