我正在運行一個簡單的PHP腳本來從遠程SQL Server獲取一些查詢。我總共有3個查詢,還有1個MySQL查詢。第一個SQL Server查詢工作正常,返回我期望的內容,然後轉到下一個$ order。這裏劇本停止了。我的意思是沒有進一步的輸出呈現給瀏覽器,結果的視圖源僅停留在以$ orders查詢開始的PHP塊之前。SQL Server查詢查殺腳本 - 無錯誤(PHP)
我的apache日誌,error_logs或其他任何地方都沒有錯誤。我還爲mssql顯示了get_last_message,它什麼也沒有顯示。在第二個mssql_query()之後鍵入或回顯任何內容。不工作,腳本停止。沒有超時,加載非常快。我在SQL Server中手動運行相同的查詢,並返回結果。
幫助?
<?php
// CHECK IF USER LOGGED IN
session_start();
if ($_SESSION['loggedIn'] != "true") {
header("Location: /reps/");
}
// GRAB DATABASE DETAILS
require('../assets/mssql_connect.php');
require('../assets/connect.php');
// SET GLOBAL REP VARIABLES
$rep = $_SESSION['name'];
$admin = $_SESSION['id'];
$customer = $_GET['id'];
$code = $_POST['Code'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../assets/css/dashstyles.css" />
<script language="javascript" src="/reps/assets/js/formvalidation.js"></script>
<title>Reps Dashboard - <?php echo $rep; ?></title>
</head>
<body>
<?php
// GET HEADER INCLUDE
require('../assets/header.php');
// BUILD QUERY USING ID TO GET FIELDS
$edit = mssql_query("SELECT * FROM Customers WHERE ID='$customer'")
or die(mssql_get_last_message());
while ($row = mssql_fetch_array($edit)) {
$code = $row['Code'];
$name = $row['Name'];
$address = $row['Address'] . "<br />" . $row['Town'] . "<br/>" . $row['County'] . "<br />" . $row['Postcode'];
$phone = $row['Tel'];
$fax = $row['Fax'];
}
mssql_free_result($edit);
?>
<div id="main">
<p class="welcome">Customer Detail: <?php echo $name; ?></p><p class="backlink"><img src="../assets/images/icons/back_icon.png" alt="Back" /> <a class="backlink" href="/reps/dashboard/">Back to dashboard</a></p>
<table class="data">
<tr>
<td style="width:40%">
<table class="data" style="width:100%">
<tr class="theader">
<td>Customer Details</td>
</tr>
<tr>
<td><p><b>Customer Code: </b><?php echo $code; ?></p>
<p><b>Address:</b><br /><?php echo $name . "<br />" . $address; ?></p>
<p><b>Tel: </b><?php echo $phone . "<br /><b>Fax: </b>" . $fax; ?></p>
</td>
</tr>
</table>
</td>
<td style="width:60%">
<table class="data" style="width:100%">
<tr class="theader">
<td>Customer Orders History</td>
</tr>
<tr>
<td>
<?php
require('../assets/mssql_connect.php');
// BUILD NEW QUERY FOR ORDERS
$orders = mssql_query("SELECT TOP 10 * FROM MainJobDetails WHERE InvoiceCustomerCode='$code'")
or die(mssql_get_last_message($orders));
// CHECK FOR 0 RECORDS
if(mssql_num_rows($orders) == 0) {
echo "No previous orders found.";
} else {
//OUTPUT PREVIOUS ORDERS
echo "Last 10 Orders<br />";
echo "<table class='orders'>";
echo "<tr><td>Date</td><td>Job Number</td><td>Description</td><td>Status</td><td>Value</td></tr>";
// ALTERNATE ROW COLOURS
$c = 0;
while ($row = mssql_fetch_array($orders)) {
$class = $c++ % 2 == 1 ? "odd" : "even";
echo "<tr class='$class'><td>";
echo $row['CreateDateTime'];
echo "</td><td>";
echo $row['JobNo'];
echo "</td><td>";
echo $row['JobDesc'];
echo "</td><td>";
echo $row['Description'];
echo "</td><td>";
echo $row['PriceEst'];
echo "</td></tr>";
}
echo "</table>";
}
mssql_free_result($orders);
?>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width:40%">
<table class="data" style="width:100%">
<tr class="theader">
<td>Comments Log</td>
</tr>
<tr>
<td>
<?php
// GET CURRENT COMMENTS
$comments = mysql_query("SELECT * FROM comments WHERE customer_id='$customer' ORDER BY id DESC LIMIT 0,5")
or die(mysql_error());
// CHECK FOR 0 COMMENTS
if(mysql_num_rows($comments) == 0) {
echo "<p>No comments about this customer.</p>";
}
// LOOP THROUGH PREVIOUS COMMENTS
while ($row = mysql_fetch_array($comments)) {
echo "<p style='line-height:20px;'><b>" . $row['rep'] . "</b> <i>(" . $row['date'] . " at " . $row['time'] . ")</i><br />";
echo $row['comment'] . "</p>";
}
?>
<form method="POST" name="comments" action="../assets/comment_post.php" onsubmit="return validateCForm();">
<textarea rows="10" cols="45" name="comment_box"></textarea><br />
<input type="hidden" name="comment_date" value="<?php echo date('d.m.Y'); ?>">
<input type="hidden" name="comment_time" value="<?php echo date('H:i:s'); ?>">
<input type="hidden" name="id" value="<?php echo $customer; ?>">
<input type="hidden" name="rep" value="<?php echo $rep; ?>"><br />
<input type="submit" class="search" name="submit" value="Post Comment">
</form>
</td>
</tr>
</table>
</td>
<td style="width:60%">
<table class="data" style="width:100%">
<tr class="theader">
<td>Customer Estimates History</td>
</tr>
<tr>
<td>
<?php
// BUILD NEW QUERY FOR QUOTES
$quotes = mssql_query("SELECT * FROM MainEstimateDetails WHERE CustomerRef = '$code' ORDER by EstimateDate DESC LIMIT 0,10")
or die (mssql_error());
// CHECK FOR 0 QUOTES
if(mssql_num_rows($quotes) == 0) {
echo "No previous quotes found.";
} else {
// OUTPUT PREVIOUS ORDERS
echo "<table class='orders'>";
echo "<tr><td>Date</td><td>Job Number</td><td>Description</td><td>Status</td><td>Value</td></tr>";
// ALTERNATE ROW COLOURS
$c = 0;
while ($row = mssql_fetch_array($quotes)) {
$class = $c++ % 2 == 1 ? "odd" : "even";
echo "<tr class='$class'><td>";
echo $row['CreateDateTime'];
echo "</td><td>";
echo $row['JobNo'];
echo "</td><td>";
echo $row['JobDesc'];
echo "</td><td>";
echo $row['description'];
echo "</td><td>";
echo $row['PriceEst'];
echo "</td></tr>";
}
echo "</table>";
}
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</body>
</html>
謝謝!
這是太多的代碼引用;請把它縮小到更合理的大小,以捕捉問題的本質;我們不需要知道你的元標籤來幫助解決這個問題。 – 2011-06-15 16:34:30
打開PHP的'display_errors'和'error_log'選項。可能有消息,但沒有記錄到任何地方和/或隱藏。 – 2011-06-15 16:35:23
(關於Paul Sonier的請求,請考慮這些指針:http://sscce.org/) – pinkgothic 2011-06-15 16:38:56