私はPHP-MYSQL Web開発に関するLuke WellingとLaura thompsonの本に従っていました.htmlに次のコードがあります:
<form action="processorder.php" method=post>
<table border=0>
<tr bgcolor=#cccccc>
<td width=150>Item</td>
<td width=15>Quantity</td>
</tr>
<tr>
<td>Tires</td>
<td align="center"><input type="text" name="tireqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td>Oil</td>
<td align="center"><input type="text" name="oilqty" size="3" maxlength="3"></td>
</tr>
<tr>
<td>Spark Plugs</td>
<td align="center"><input type="text" name="sparkqty" size="3"
maxlength="3"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit Order"></td>
</tr>
</table>
</form>
<tr>
<td>How did you find Bob's</td>
<td><select name="find">
<option value = "a">I'm a regular customer
<option value = "b">TV advertising
<option value = "c">Phone directory
<option value = "d">Word of mouth
</select>
</td>
</tr>
そしてphpのこのコード:
<html>
<head>
<title>Bob's Auto Parts - Order Results</title>
</head>
<body>
<h1>Bob's Auto Parts</h1>
<h2>Order Results
<?php
//create short variable names
$tireqty = $_POST['tireqty'];
$oilqty = $_POST['oilqty'];
$sparkqty = $_POST['sparkqty'];
echo '<p>Order processed at ';
echo date('H:i, jS F');
echo '</p>';
echo '<p>Your order is as follows: </p>';
echo "$tireqty tires<br />";
echo "$oilqty bottles of oil<br />";
echo "$sparkqty spark plugs<br />";
$totalqty = 0;
$totalqty = $tireqty + $oilqty + $sparkqty;
echo 'Items ordered: '.$totalqty.'<br />';
$totalamount = 0.00;
define('TIREPRICE', 100);
define('OILPRICE', 10);
define('SPARKPRICE', 4);
$totalamount = $tireqty * TIREPRICE
+ $oilqty * OILPRICE
+ $sparkqty * SPARKPRICE;
echo 'Subtotal: $'.number_format($totalamount,3).'<br />';
$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
echo 'Total including tax: $'.number_format($totalamount,2).'<br />'
switch($find)
{
case "a":
echo "<p>Regular customer.</p>";
break;
case "b" :
echo "<p>Customer referred by TV advert.</p>";
break;
case "c" :
echo "<p>Customer referred by phone directory.</p>";
break;
case "d" :
echo "<p>Customer referred by word of mouth.</p>";
break;
default :
echo "<p>We do not know how this customer found us.</p>";
break;
}
?>
</h2>
</body>
</html>
送信ボタンを押すとサーバーエラーが発生します。スイッチブロックが問題の原因です。PhP 5.3.10 を使用しています。誰でも私に問題を指摘できますか?前もって感謝します。