0

重複の可能性:
警告: mysql_fetch_* はパラメーター 1 がリソースであると想定し、ブール値のエラーが発生しました

このエラーを修正しようとしましたが、できません

このエラーは、一部の結果でのみ発生します。

これがコードです

    <?php 

    while($rs = mysql_fetch_array($sql)) { 

        echo "<tr>" ?>

       <form id="ingreso_nota" method="post" action="editnotasql.php">

        <td><input type="text" name="nota_1" value="<?php echo $rs["nota_1"] ?>" /></td> 

        <td><input type="text" name="nota_2" value="<?php echo $rs["nota_2"] ?>" /></td> 

        <td><input type="text" name="nota_3" value="<?php echo $rs["nota_3"] ?>" /></td>

        <td><input type="text" name="nota_4" value="<?php echo $rs["nota_4"] ?>" /></td>

        <td><input type="text" name="nota_5" value="<?php echo $rs["nota_5"] ?>" /></td>

        <td><input type="text" name="nota_6" value="<?php echo $rs["nota_6"] ?>" /></td>

        <td><input type="text" name="nota_7" value="<?php echo $rs["nota_7"] ?>" /></td>

        <td><input type="text" name="nota_8" value="<?php echo $rs["nota_8"] ?>" /></td> 

        <input type="hidden" name="rut" value="<?php echo $rs["rut"] ?>">

        <input type="hidden" name="id_asig" value="<?php echo $rs["id_asig"] ?>">



       <?php 

       echo "</tr>"; 

       } 

これは複数の行を持つテーブルを生成しましたが、そのうちの1つだけがこのエラーを返します

これはクエリSQLです

            $rut =$_GET["rut"];

            $id_asig =$_GET["asignatura"];
            $nombre =$_GET["nombre"];
            $curso =$_GET["curso"];
$sql = "SELECT * FROM calificaciones WHERE rut=$rut AND id_asig=$id_asig" ; 
            $sql = mysql_query($sql, $con)  ; 
4

2 に答える 2

0

Sometimes that warning is that if the result of the query within while returns no value, that is, such as when no records on table.

What I mean is that in some cases your code and your application is correct and yet the warning appears.

to hide the warning uses the character @.

e.g.

while(@$rs = mysql_fetch_array($sql)) {
   ...
}

Best regards

于 2012-10-24T14:11:51.153 に答える
0

SQL 構文エラーがあるため、結果セットを取得できません。mysql_error() 関数を使用して、データベースのクエリ中にエラーを確認してください。

変化する

$sql = "SELECT * FROM calificaciones WHERE rut=$rut AND id_asig=$id_asig" ; 

$sql = "SELECT * FROM calificaciones WHERE rut='{$rut}' AND id_asig='{$id_asig}'" ; 

注: クエリは MySQL インジェクションの影響を受ける必要があります。

于 2012-10-24T12:36:58.157 に答える