我一直在試圖解決這個問題,現在我的問題已經解決了。該代碼是顯示從保險箱中選擇的工作正常..但是當我把它放在我的佈局/模板它會拋出一個錯誤&我不知道爲什麼!
下面的代碼:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="" >
<meta name="description" content="" >
<meta http-equiv="content-type" content="text/html; charset=utf-8" >
<title>SNYSB Archive</title>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" >
<!-- Location of javascript. -->
<script language="javascript" type="text/javascript" src="swfobject.js" ></script>
</head>
<div id="wrapper">
<div id="header">
<!-- KEEP THIS BIT [ITS FORMATTING] -->
</div>
<!-- end #header -->
<div id="menu">
<ul>
<li><a href="Hpage.php">Home</a></li>
<li><a href="Register.php">Register</a></li>
</ul>
</div>
<!-- end #menu -->
<div id="page">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
<div class="post">
<div class="post-bgtop">
<div class="post-bgbtm">
<h1 class="title">PUT HEADING HERE!</h1>
<div class="entry">
<p class="Body">
<?php
$dbname = 'snysbarchive';
$conn= mysql_connect('localhost', 'root', 'usbw');
if (!$conn) {
echo 'Could not connect to mysql';
exit;
}
$sql = "SHOW TABLES FROM $dbname";
$result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
if (mysql_select_db($dbname, $conn))
{
?>
<form method="post" action="new 2.php">
<select name="tables">
<?php
while ($row = mysql_fetch_row($result)) {
?>
<?php
echo '<option value="'.$row[0].'">'.$row[0].'</option>';
}
?>
</select>
<input type="submit" value="Show">
</form>
<?php
//mysql_free_result($result);
if (isset($_POST) && isset($_POST['tables']))
{
$tbl=$_POST['tables'];
//echo $_POST['tables']."<br />";
$query="SELECT * from $tbl";
$res=mysql_query($query);
echo $query;
if ($res)
{
?>
<table border="1">
<?php
while ($row = mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>".$row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "<td>".$row[3]."</td>";
echo "</tr>";
} ?>
</table>
<?php
}
}
?>
</div>
</div>
</div>
</div>
<div style="clear: both;"> </div>
</div>
<!-- end #content -->
<div id="sidebar">
<ul>
<li>
<h2>Welcome!</h2>
<p>Welcome to SNYSBs archive!
</p>
</li>
<li>
<h2>SNYSB</h2>
<p>
<a href="Contact.php">Contact Us!</a>
</p>
</li>
</ul>
</div>
<!-- end #sidebar -->
<div style="clear: both;"> </div>
</div>
</div>
</div>
<!-- end #page -->
<div id="footer">
<p>Copyright (c) 2008 Sitename.com. All rights reserved. Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>.</p>
</div>
<!-- end #footer -->
</div>
</body>
</html>
(只粘貼了整個頁面的代碼從原來的我開始和底部模板)
這是該行它不喜歡:
if (isset($_POST['tables']))
謝謝
編輯:新錯誤信息: 解析錯誤:語法錯誤,在第128行的FILENAME中出現意外的$ end
發佈您嘗試排除故障的錯誤很有用,尤其是考慮到上述代碼中存在多個語法錯誤。 – bkconrad 2012-03-11 17:55:53
這個錯誤顯然是與if(isset($ _ POST ['tables'])) 這一行我不明白的是,代碼工作完全罰款..但是,當我添加格式代碼上面和下面這一節它的嘔吐錯誤 – AisRuss 2012-03-11 18:14:18
現在你在結尾缺少一個右括號:)我相信:) – bkconrad 2012-03-11 19:38:00