我无法确定此脚本中的错误位置。尝试添加验证后出现错误。
我才刚刚开始用 php 编码,所以请原谅 ;)
错误读取 Parse error: syntax error, unexpected end of file in C:\xampp\htdocs\index.php 在第 84 行
请帮忙:(
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
//debugging^
function p($array) {
echo '<pre>';
print_r($array);
echo '</pre>';
}
$con = mysql_connect("localhost","root","password1");
if (! $con) {
die('Could not connect: ');
}
mysql_select_db("inimaxedwards", $con);
$result = mysql_query("SELECT * FROM wishlist");
echo "<table border='1' width=600px>
<tr>
<th>Item</th>
<th>Cost</th>
<th>Website</th>
</tr>";
while($row = mysql_fetch_array($result)) { //p($row);
echo "<tr>";
echo "<td>" . $row['Item'] . "</td>";
echo "<td>" . $row['Cost'] . "</td>";
echo "<td>" . $row['Website'] . "</td>";
echo "</tr>";
}
//validation below
$itemErr = $costErr = $websitErr;
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["item"])) {
$itemErr = "You need to enter an item";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["cost"])) {
$costErr = "How much is the item?";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["website"])) {
$websiteErr = "Please provide a link for item!";
}
echo "</table>";
mysql_close($con);
?>
<form action="insert.php" method="post">
Item: <input type="text" name="item">
Cost: <input type="text" name="cost">
Website: <input type="text" name="website">
<input type="submit">
</form>
</body>
</html>