其演示此錯誤 警告:mysql_fetch_array()預計參數1是資源,在布爾C中給出:\瓦帕\ WWW \ ocwconnection \用戶\ search.php中第18行如何解決對於MySQL這顯示錯誤獲取數組
我無法理解爲什麼會這樣,因爲我有很多文件相同的代碼,但請幫我謝謝
**search.php**
<!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>
<title>Search results</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
<?php
$con = mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error());
$db = mysql_select_db("ocw_connection") or die(mysql_error());
// var_dump($db); exit;
$sql = "SELECT * FROM ocwconnections WHERE FormDistributionDate BETWEEN `fromdate` AND `todate` ";
$query = mysql_query($sql);
var_dump($query); exit;
echo "<table>";
echo "<thead><tr><td>Serial No.</td><td>Zone</td><td>Distrbuted Date</td><td>Form no.</td><td>Consumer Name</td><td>Address</td><td>Telephone No.</td><td>Completed Form Received Date</td><td>TLs Name</td><td>Date of Handover to TL</td><td>Site visit date by TL</td><td>Handover date to SPM</td><td>O&M Name</td><td>Handover date to O&M </td><td>Date of Estimate Prepared</td><td>Estimate Amount INR (Technical)</td><td>Date of Estimate recevied from O&M</td><td>Deposits/Other Chareges INR (Commercial)</td><td>Final Demand Amount INR</td><td>Date of submission for approved to delegate</td><td>Date of approval</td><td>Date of Demand Details given to Consumer</td><td>Demand Paid Date</td><td>Handover to O&M for Execuation</td><td>Connection Date</td><td>Date of Commencement of Water supply</td><td>Billig Started</td><td>Date provided to Billing Section for Entry</td><td>Date of Data Entry by Billing Section</td><td>Status</td><td>Reason</td><td>Comment</td><td>Ageing with CS</td><td>Ageing with O&M (Estimate)</td><td>Ageing with Delegate/EE</td><td>Ageing for Payment</td><td>Ageing with O&M (Connection)</td><td>Ageing with Commencement of Water</td><td>Ageing for Billing</td><td>Total Ageing</td><td>Recevied Month</td><td>Connection Month</td><td>CIN</td><td>ReceiptNumber</td> </tr></thead>";
while($row = mysql_fetch_array($query))
{
echo "<tr><td>$row[ID]</td><td>$row[ZoneID]</td><td>$row[FormDistributionDate]</td><td>$row[FormNo]</td><td>$row[ConsumerName]</td><td>$row[Address]</td><td>$row[TelephoneNo]</td><td>$row[CompletedFormReceivedDate]</td><td>$row[TLsName]</td><td>$row[DateOfHandoverToTL]</td><td>$row[SiteVisitDateByTL]</td><td>$row[HandoverDateToSPM]</td><td>$row[OMName]</td><td>$row[HandoverDateToOM]</td><td>$row[DateOfEstimatePrepared]</td><td>$row[EstimateAmountINRTechnical]</td><td>$row[DateOfEstimateReceviedFromOM]</td><td>$row[DepositsOtherCharegesINRCommercial]</td><td>$row[FinalDemandAmountINR]</td><td>$row[DateOfSubmissionForApprovedToDelegate]</td><td>$row[DateOfApproval]</td><td>$row[DateOfDemandDetailsGivenToConsumer]</td><td>$row[DemandPaidDate]</td><td>$row[HandoverToOMForExecuation]</td><td>$row[ConnectionDate]</td><td>$row[DateOfCommencementOfWaterSupply]</td><td>$row[BilligStarted]</td><td>$row[DateProvidedToBillingSectionForEntry]</td><td>$row[DateOfDataEntryByBillingSection]</td><td>$row[StatusID]</td><td>$row[Reason]</td><td>$row[Comment]</td><td>$row[AgeingWithCS]</td><td>$row[AgeingWithOMEstimate]</td><td>$row[AgeingWithDelegateEE]</td><td>$row[AgeingForPayment]</td><td>$row[AgeingWithOMConnection]</td><td>$row[AgeingWithCommencementOfWater]</td><td>$row[AgeingForBilling]</td><td>$row[TotalAgeing]</td><td>$row[ReceviedMonth]</td><td>$row[ConnectionMonth]</td><td>$row[CIN]</td><td>$row[ReceiptNumber]</td></tr>";
}
echo "</table>";
?>
</body>
</html>
**index.php**
<?php
//------------------------------------------------------------
// RESTRICT ACCESS TO PAGE
//------------------------------------------------------------
require_once('../web.config.php'); require_once(ROOT_PATH.'global.php');
$auth_roles = array('owner','superadmin','administrator','member','user');// << add roles here
require_once(ROOT_PATH.'modules/authorization/auth.php');
require_once(ROOT_PATH.'DBconnect.php');
?>
<!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=utf-8" />
<title>Untitled Document</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script language="JavaScript" type="text/javascript">
$(function() {
$("#datepicker20").datepicker(({ dateFormat: "yy-mm-dd" }));
$("#datepicker21").datepicker(({ dateFormat: "yy-mm-dd" }));
});
</script>
</head>
<body>
<form action="search.php" method="get">
<input type="text" name="fromdate" id="datepicker20" />
<input type="text" name="todate" id="datepicker21" />
<input type="submit" value="Search" />
</form>
</body>
</html>
在'mysql_query()'後面運行'echo mysql_error()'。請記住,'mysql_ *'函數已被棄用。 –