這可能是一個n00b的問題,但我不能爲我的生活弄清楚我搞砸了什麼。我以前有過類似的問題,但我認爲我更多地修復了它而不是設計,我真的很想知道我實際上做了什麼錯誤。神祕500錯誤
如果我在pastebin中運行代碼,我得到一個500錯誤。但是,如果我將display_wine函數註釋掉,它會非常好地運行。如果我運行調試器,它會突出顯示關閉的php標籤。我已經檢查並進行了雙重檢查,以確保我沒有任何其他的括號或分號。任何幫助將不勝感激!
<?php
class simpleCMS {
var $host;
var $username;
var $password;
var $table;
var $id;
public function display_wine_list() {
$q = "SELECT * FROM whino ORDER BY created DESC LIMIT 3";
$r = mysql_query($q);
if ($r !== false && mysql_num_rows($r) > 0) {
while ($a = mysql_fetch_assoc($r)) {
$id = $a['id'];
$name = stripslashes($a['name']);
$created = $a['created'];
$type = $a['type'];
/**
$evalt = "require_once '../generator/qrlib.php';";
eval($evalt);
QRcode::png('http://qr.htbx.net/simplecms/mob_display.php?id='.$id, '../generator/temp/'.$id.'.png');
**/
$entry_display .= <<<ENTRY_DISPLAY
<div class="post">
<h2>
$name
</h2>
<p>$created</p>
<p>$type</p>
</div>
ENTRY_DISPLAY;
}
} else {
$entry_display = <<<ENTRY_DISPLAY
<h2> This Page Is Under Construction </h2>
<p>
No entries have been made on this page.
Please check back soon, or click the
link below to add an entry!
</p>
ENTRY_DISPLAY;
}
$entry_display .= <<<ADMIN_OPTION
<p class="admin_link">
<a href="{$_SERVER['PHP_SELF']}?admin=1">Add a New Entry</a>
</p>
ADMIN_OPTION;
return $entry_display;
}
public function display_admin() {
return <<<ADMIN_FORM
<form action="{$_SERVER['PHP_SELF']}" method="post">
<label for="name">Name:</label><br />
<input name="name" id="name" type="text" maxlength="75" />
<div class="clear"></div>
<label for="type">Type:</label><br />
<input name="type" id="type" type="text" maxlength="100" />
<div class="clear"></div>
<label for="notes">Notes:</label><br />
<textarea name="notes" id="notes"></textarea>
<div class="clear"></div>
<input type="submit" value="Create This Entry!" />
</form>
<br />
<a href="display.php">Back to Home</a>
ADMIN_FORM;
}
public function write($p) {
if ($_POST['name'])
$name = mysql_real_escape_string($_POST['name']);
if ($_POST['type'])
$type = mysql_real_escape_string($_POST['type']);
if ($_POST['grapes'])
$grapes = mysql_real_escape_string($_POST['grapes']);
if ($_POST['notes'])
$notes = mysql_real_escape_string($_POST['notes']);
if ($name && $type && $grapes && $notes) {
$created = date ("Y-m-d H:i:s", $phptime);
$sql = "INSERT INTO whino VALUES('','$name','$type','$grapes', '$notes')";
return mysql_query($sql);
} else {
return false;
}
}
public function connect() {
mysql_connect($this->host,$this->username,$this->password) or die("Could not connect. " . mysql_error());
mysql_select_db($this->table) or die("Could not select database. " . mysql_error());
return $this->buildDB();
}
private function buildDB() {
$sql = <<<MySQL_QUERY
CREATE TABLE IF NOT EXISTS whino (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(75),
notes TEXT,
created DATE,
type VARCHAR(100),
grapes VARCHAR(75)
)
MySQL_QUERY;
return mysql_query($sql);
}
public function display_wine($id) {
$q = "SELECT * FROM whino WHERE id = $id";
$r = mysql_query($q);
if ($r !== false && mysql_num_rows($r) > 0) {
while ($a = mysql_fetch_assoc($r)) {
$id = $a['id'];
$name = stripslashes($a['name']);
$created = $a['created'];
$type = $a['type'];
$entry_display .= <<<ENTRY_DISPLAY
<div class="post">
<h2>
$name
</h2>
<p>$created</p>
<p>$type</p>
</div>
ENTRY_DISPLAY;
}
} else {
$entry_display = <<<ENTRY_DISPLAY
<h2> This Page Is Under Construction </h2>
<p>
No entries have been made on this page.
Please check back soon, or click the
link below to add an entry!
</p>
ENTRY_DISPLAY;
}
$entry_display .= <<<ADMIN_OPTION
<p class="admin_link">
<a href="{$_SERVER['PHP_SELF']}?admin=1">Edit</a>
</p>
ADMIN_OPTION;
return $entry_display;
}
}
?>
該代碼沒有聲明一個類。你應該檢查你的apache錯誤日誌,以便進一步瞭解發生的錯誤。 – Alp