Welcome to WebmasterWorld Guest from 54.146.246.4

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

PHP Syntax Error

I'm kind of new to PHP and I'm executing a program for my class, but it

     

KWilson

3:17 am on Oct 13, 2012 (gmt 0)



I'm kind of new to PHP and I'm executing a program for my class, but it keeps saying { [syntax error, unexpected $end, expecting '`' on line 79 } which is the last line of the program that contains no code.. help! i've included the entire code below



<html>
<head>
<title> Automobile Repair Cost </title>
<link rel="stylesheet" type="text/css" href="mypage.css"/>
</head>
<body>
<?php

// receive input from lab5a-1.html

$custName = $_POST['custName'];

$hoursLabor = $_POST['hoursLabor'];

$partsCost = $_POST['partsCost'];

$selectGarage = $_POST['selectGarage'];

//compute $laborCost,$partsCostTax, $partsCostTotal,$totalCost
if ($selectGarage == 1)
{
print ("<p> You selected a Dealer to repair your car. </p>");
$laborCost = 35 * $hoursLabor;
$partsCostTax = $partsCost * .05;
$partsCostTotal = $partsCost + $partsCostTax;
$totalCost = $laborCost + $partsCostTotal;
}
else if ($selectGarage == 2)
{
print ("<p> You selected a Local garage to repair your car.</p>");
$laborCost = 30 * $hoursLabor;
$partsCostTax = $partsCost * .085;
$partsCostTotal = $partsCost + $partsCostTax;
` $totalCost = $laborCost + $partsCostTotal;
}
else
{
print("<p> $selectGarage is an invalid garage selection! Cannot process</p>");
$laborCost = 0;
$partsCostTax = 0;
$totalCost = 0;
}
//display $custName,$selectGarage,$hoursLabor, $laborCost,$partsCostTotal,$totalCost

print ("<p>The customerís name is: $custName</p>");
print ("<p>The garage selected is: $selectGarage</p>");
print ("<p>The hours of labor required to fix your car: $hoursLabor</p>");
print ("<p>The cost for labor to repair your car: $laborCost</p>");
print ("<p>The cost for parts and supplies including tax: $partsCostTotal</p>");
print ("<p>The total cost to repair your car is: $totalCost<p>");
?>
<style type="text/css">

body { padding-left: 11em;font-family:cursive, "Segoe Print", Times, serif; color: blue; background-color: 66FF99 }
ul.navbar { list-style-type: none;
padding: 0;
margin: 0;
position: absolute;
top: 2em;
left: 1em;
width: 9em }
h1{
font-family: Helvetica, Geneva, Arial, SunSans-Regular, sans-ser
ul.navbar li {
background: white;
margin: 0.5em 0;
padding: 0.3em;
border-right: 1em solid black }
ul.navbar a { text-decoration: none }
a:link {color: red }
a:visited { color: purple }
address {
margin-top: 1em;
padding-top: 1em;
border-top: thin dotted }
</style>
</body>
</html>

JohnNZ

3:28 am on Oct 13, 2012 (gmt 0)



` $totalCost = $laborCost + $partsCostTotal;


Is that a spurious character at the beginning of the line?

Austin80ss

11:51 am on Oct 17, 2012 (gmt 0)



Unexpected $end is a common error if you didn't close block structure in your code. (like: if(){..;} , for(){..;})

lucy24

10:56 pm on Oct 17, 2012 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Is that a spurious character at the beginning of the line?

... and if yes, does that mean the program is now holding its breath-- possibly forever-- waiting for a matching ` to close it all up?

ericlewis107

11:17 am on Dec 3, 2012 (gmt 0)



Although, since you're still learning, I suggest you move straight away from the mysql_* library. It's very old, slow, and insecure. Instead, look at the improved MySQLi version or PDO. It does look more complicated at the beginning, but you won't regret it.

swa66

10:34 pm on Dec 3, 2012 (gmt 0)

WebmasterWorld Senior Member swa66 is a WebmasterWorld Top Contributor of All Time 10+ Year Member



As far as security goes, this is an open door for XSS (Cross Site Scripting)

Ref: [owasp.org...]

You must encode output ... and/or validate input.