-1

IT はこのエラーを表示します 警告: mysql_fetch_array() は、パラメーター 1 がリソースであると想定し、18 行目の C:\wamp\www\ocwconnection\user\search.php で指定されたブール値です

多くのファイルに同じコードがあるため、なぜこれが起こっているのか理解できませんが、助けてくださいありがとう


**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>
4

4 に答える 4

0

行をフェッチする前に、必ず出力を確認してください。クエリにエラーがあります。

これを試してください:

if(!$query)
{
echo mysqli_error();
}else{
  while( $row = mysqli_fetch_array( $query ) )
     {
   //fetch rows
     }

そうすることで、正確なエラーを知ることができます。( の使用は避けmysql、代わりに を使用してくださいmysqli)

于 2013-11-01T11:11:10.597 に答える
0

SQL クエリが間違っています。

SELECT * FROM ocwconnections WHERE FormDistributionDate BETWEEN `fromdate` AND `todate`

` で囲まれた文字列は列名と見なされます。そこに変数が必要なようです。

$fromdate = $_GET['fromdate'];
$todate= $_GET['todate'];
$sql = "SELECT * FROM ocwconnections WHERE `FormDistributionDate` BETWEEN $fromdate AND $todate ";

これは動作するはずです (テストされていません)。

これにより、スクリプトが SQL インジェクションに対して開かれることに注意してください。mysqli_*関数または PDO に切り替えて、準備済みステートメントを使用します。

于 2013-11-01T11:12:07.837 に答える