0

Here is my code:

<?php
  if ($_POST["p_500"] or $_POST["p_750"] or $_POST["p_1000"] or //line 2
  $_POST["p_1250"] or $_POST["p_1500"] or $_POST["p_1750"] or 
  $_POST["p_2000"] or $_POST["p_2500"] or $_POST["p_3000"] or 
  $_POST["p_4000"] or $_POST["p_5000"] or $_POST["p_6000"] or 
  $_POST["p_7000"] or $_POST["p_8000"] or $_POST["p_10000"]) {
      if ($_POST["p_500"]) {$a0=0;$b0=500;
      } else {$a0=100000;$b0=0;}
      if ($_POST["p_750"]) {$a1=500;$b1=750;
      } else {$a1=100000;$b1=0;}
      if ($_POST["p_1000"]) {$a2=750;$b2=1000;
      } else {$a2=100000;$b2=0;}
      if ($_POST["p_1250"]) {$a3=1000;$b3=1250;
      } else {$a3=100000;$b3=0;}
      if ($_POST["p_1500"]) {$a4=1250;$b4=1500;
      } else {$a4=100000;$b4=0;}
      if ($_POST["p_1750"]) {$a5=1500;$b5=1750;
      } else {$a5=100000;$b5=0;}
      if ($_POST["p_2000"]) {$a6=1750;$b6=2000;
      } else {$a6=100000;$b6=0;}
      if ($_POST["p_2500"]) {$a7=2000;$b7=2500;
      } else {$a7=100000;$b7=0;}
      if ($_POST["p_3000"]) {$a8=2500;$b8=3000;
      } else {$a8=100000;$b8=0;}
      if ($_POST["p_4000"]) {$a9=3000;$b9=4000;
      } else {$a9=100000;$b9=0;}
      if ($_POST["p_5000"]) {$a10=4000;$b10=5000;
      } else {$a10=100000;$b10=0;}
      if ($_POST["p_6000"]) {$a11=5000;$b11=6000;
      } else {$a11=100000;$b11=0;}
      if ($_POST["p_7000"]) {$a12=6000;$b12=7000;
      } else {$a12=100000;$b12=0;}
      if ($_POST["p_8000"]) {$a13=7000;$b13=8000;
      } else {$a13=100000;$b13=0;}
      if ($_POST["p_10000"]) {$a14=8000;$b14=10000;
      } else {$a14=100000;$b14=0;}
      $price_lower=min($a0,$a1,$a2,$a3,$a4,$a5,$a6,$a7,$a8,$a9,$a10,$a11,$a12,$a13,$a14);
      $price_upper=max($b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9,$b10,$b11,$b12,$b13,$b14);
      $sql_new_string=" AND price<$price_upper AND price=>$price_lower";
      $sql=$sql.$sql_new_string;
  }
?>

When I run it I get the following error:

Parse error: syntax error, unexpected ' ' (T_STRING) in C:\wamp64\x\x\x.php on line 2

Can someone please tell me why I am getting this error?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
midav
  • 91
  • 2
  • 7
  • Good news: that code ***→as posted here←*** does not contain any syntax errors. -- And now the bad news: that's probably the least maintainable gibberish posted today. – mario Nov 16 '17 at 23:42

1 Answers1

0

To fix this, we can either start the string with a double quote or use single quotes throughout and escape the apostrophe:

Example :echo 'It\'s time to stop writting errors ';

Or use \_

Artier
  • 1,648
  • 2
  • 8
  • 22