bateman Posted September 3, 2010 Share Posted September 3, 2010 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 https://forums.phpfreaks.com/topic/212471-parse-error-syntax-error-unexpected-in-home/ Share on other sites More sharing options...
wildteen88 Posted September 3, 2010 Share Posted September 3, 2010 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 https://forums.phpfreaks.com/topic/212471-parse-error-syntax-error-unexpected-in-home/#findComment-1106975 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.