<?php
$sql = mysql_connect("localhost" , "root" , "usbw") or die(mysql_error);
mysql_select_db("guestbook" , $sql);
if($_SERVER['REQUEST_METHOD'] == 'POST') (
$user = mysql_real_escape_string($_POST['user']);
$message = mysql_real_escape_string($_POST['message']);
$query = mysql_query("INSERT INTO message (user,message) VALUES ('$user' , '$message'");
echo ("Message succesfully added.");
)
?>
<html>
<head>
<title>Guestbook</title>
</head>
<form action="index.php" method="post">
User: <input type="text" name="user"/><br>
Message: <textarea name="message"></textarea>
<input type="submit" value="Post!"/>
</form>
</html>
<?php
$result = mysql_query("SELECT * FROM message ORDER BY id DESC");
while($row = mysql_fetch_array($result)) (
)
?>
<table>
<tr>
<td>User:</td>
<td><?php echo $row['user'] ?></td>
</tr>
<td>Message:</td>
<td><?php echo $row['message'] ?></td>
</table>
<hr />
<?php
)
?>
嘿!我正在尝试创建一个简单的 php 留言簿,但我不断收到以下错误:
解析错误:语法错误,意外的 ';' 在
第 7 行的 /Applications/XAMPP/xamppfiles/htdocs/g_book/index.php
任何人都可以看到我要去哪里错了吗?