这是第一个网页<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title></title>
</head><body>
<?php 
require_once('db_login.php');
require_once('DB.php');

$connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
if (DB::isError($connection))
{
die("Could not connect to the data:<br />".DB::errorMessage($connection));
}

$query = "select * from books";
$result = $connection->query($query);
if (DB::isError($result))
{
die("could not query to the dat:<br />".DB::errorMessage($result));
}

echo ('<table border = "1">
<tr><th>Title</th><th>Pages</th><th>Buy</th></tr>');
while ($result_row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
echo "<tr><td>";
echo $result_row["title"].'</td><td>';
echo $result_row["pages"].'</td><td>';
echo '<a href = "purchase.php?title_id = '.$result_row["title_id"].'">Click to purchase</a></td></tr>';/*在这里通过超链接把title_id传给第二个网页*/
}

echo "</table>";
$connection->disconnect();


?>
</body>
</html>
这是第二个网页
<?php 
require_once('db_login.php');
require_once('DB.php');

$connection = DB::connect("mysql://$db_username:$db_password@$db_host/$db_database");
if (DB::isError($connection))
{
die ("Could not connect to the data:<br />". DB::errorMessage($connection));
}

$title_id = $_GET["title_id"];/*在这里得到,但是我用echo输出¥title_id时却什么也没有,不知问题在哪里*/
if (get_magic_quotes_gpc())
{
$title_id = stripslashes($title_id);
}
$title_id = mysql_real_escape_string($title_id);

$user_id = 'Ary';
$query = "insert into purchases values(NULL, '$user_id', $title_id, NULL)";/*这里提示语法错误*/
$result = $connection->query($query);
if (DB::isError($result))
{
die ("Could not query to the data:<br />". DB::errorMessage($result));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="refresh" content="30; url = pear_purchase_example.php" />
<title></title>
</head><body>
Thanks for your purchase!<br />
<?php 
$query = "select * from purchases natural join books natural join authors";
$result = $connection->query($query);
if (DB::isError($result))
{
die ("Could not query to the data:<br />".DB::errorMessage($result));
}

echo '<table border = "1">';
echo "<tr><th>User</th><th>Title</th><th>Pages</th><th>Author</th><th>Purchased</th></tr>";
while ($result_row = $result->fetchRow(DB_FETCHMODE_ASSOC))
{
echo "<tr><td>";
echo $result_row["user_id"].'</td><td>';
echo $result_row["title"].'</td><td>';
echo $result_row["pages"].'</td><td>';
echo $result_row["author"].'</td><td>';
echo $result_row["purchased"].'</td></tr>';
}
echo "</table>";

$connection->disconnect();
?>
</body>
</html>求各位大虾帮帮忙呀··············