-2
編輯 問題解決了,使用了錯誤報告,發現這是雙引號與單引號的問題。PHP/MySQL代碼問題
我在獲取這個PHP/mySQL代碼顯示任何問題。因爲它只是顯示一個空白的白頁。我插入一個簡單的打印命令到代碼的不同部分,只要它的外面將打印聲明:
} else {
print "<p>Error: Couldn't find Confirmation code</p>";
}
if($updater){
print "<p>Thank you" . $username . ", you have been confirmed and can now access our members page.</p>";
}
部分。這讓我相信這是這個領域的一個問題,或者我的if/else語句。
<html>
<head>
<title>CS148 "Where Are You From?" Confirmation Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Stephen B. Wakita" />
<meta name='description' content='Confirm Page for CS148 PHP Form Assignment.'/>
<link rel="stylesheet" href="mystyle.css" type="text/css" media="screen" />
</head>
<body>
<?php
$dbh = mysql_connect('webdb.uvm.edu','swakita','password');
if(!$dbh)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('SWAKITA', $dbh);
$confnum = mysql_real_escape_string($_GET['confnum']);
$tblname = mysql_real_escape_string('tblWhere');
$sql = "SELECT * FROM $tblname WHERE fldConfirm='$confnum'";
$check = mysql_query($sql);
if($check) {
$count = mysql_num_rows($check);
if($count == 1) {
$rows = mysql_fetch_array($check);
$username = $rows['pk_Username'];
$sql2 = "UPDATE $tblname(fldAdminLevel)VALUES('4')";
$updater = mysql_query($sql2);
} else {
print "<p>Error: Couldn't find Confirmation code</p>";
}
if($updater) {
print "<p>Thank you" . $username . ", you have been confirmed and can now access our members page.</p>";
}
}
?>
</body>
</html>
在php.ini中打開錯誤報告。嘗試向else語句前面的if語句添加一些調試輸出,以便測試是否存在邏輯錯誤。 – 2012-03-07 22:25:05
請正確縮進您的代碼。 – Ryan 2012-03-07 22:25:22
你確定dB連接有效嗎? – 2012-03-07 22:26:17