Jump to content

Parse error: syntax error, unexpected '=' in /home/...


bateman

Recommended Posts

the code is

<?php 
$qty=$_POST['quantity'];
$service=$_POST['service'];
$reciept=$_POST['reciept'];

if (service=SC1) {$desc="Hourly Service"; $price = "20";}
elseif (service=SC2) {$desc="Hourly Service - Half hour"; $price = "10";}
elseif (service=SC3) {$desc="Hourly Service - Extended area"; $price = "30";}
elseif (service=SC5) {$desc="Virus Removal / Computer Cleanup"; $price = "40";}
elseif (service=cl1) {$desc="Physical Cleaning of computer"; $price = "10";}
elseif (service=ba1) {$desc="Data backup \$1 per 5gb"; $price = "1";}
elseif (service=OS1) {$desc="Windows XP install"; $price = "50";}
elseif (service=OS2) {$desc="Windows Vista install"; $price = "50";}
elseif (service=OS3) {$desc="Windows 7 install"; $price = "50";}
elseif (service=OS4) {$desc="Windows XP install - No disk"; $price = "50";}
elseif (service=OS5) {$desc="Windows Vista install - No disk"; $price = "120";}
elseif (service=OS6) {$desc="Windows 7 install - No disk"; $price = "250";}
elseif (service=OS6) {$desc="Linux install"; $price = "50";}
elseif (service=OS6) {$desc="Linux install - No disk"; $price = "60";}

$total = $price * $qty;
mysql_select_db($database_local, $local);
{
$sql=mysql_query("INSERT INTO service (qty, item, description, price, discount, total, reciept) VALUES('$qty','$service','$desc', '$price', '$discount', '$total', '$reciept') ") or die(mysql_error());   
$result=mysql_query($sql);
} 

 

I've looked it over myself and run a syntax checker, neither can find an error

Link to comment
Share on other sites

Well the problem is with your if/elseif statements,

if (service=SC1) {$desc="Hourly Service"; $price = "20";}
...

All strings must be wrapped in strings, unless SC1 is a constant? Also service should $service. Lastly the == is the comparison operator, and = is the assignment operator.

 

However you will be better off changing your if/elseif block into a switch/case statemment instead.

 

Whats with the curly braces ({ and }) here?

{
$sql=mysql_query("INSERT INTO service (qty, item, description, price, discount, total, reciept) VALUES('$qty','$service','$desc', '$price', '$discount', '$total', '$reciept') ") or die(mysql_error());   
$result=mysql_query($sql);
} 

Thats invalid syntax, you should remove those.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.