mysqli_fetch_array()没有获取结果

时间:2017-07-05 00:09:18

标签: php html mysql

请我的代码有问题...我做了一个选择查询,它显示附加的IMAGE中的错误...代码也附加...请问可能是错误....

图片上传....以下是错误...

( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource, object given in C:\wamp\www\testpro\admin\categories.php on line 91
Call Stack
#   Time    Memory  Function    Location
1   0.0025  143568  {main}( )   ..\categories.php:0
2   0.0620  153304  mysql_fetch_array ( )   ..\categories.php:91

以下是" CATEGORIES.PHP" ///

的完整代码
<?php

include '../dbconnect.php';

if(isset($_POST['cat_submit'])){

$cat_name = $_POST['cat_name'];
$cat_desc = $_POST['cat_desc'];
//insert catogory into cat table
$sql = "INSERT INTO categories(cat_name,cat_desc) VALUES('$cat_name','$cat_desc')";
mysqli_query($conn, $sql);
}

?>

<!DOCTYPE html>
<html lang="en">


<HEAD>

    <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="">


<title>TEST PRO || CATEGORY</title>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="../css/testpro.css"/>
<link rel="stylesheet" type="text/css" href="../css/font-awesome.min.css"/>

</HEAD>
<body style="overflow-y: visible;">

<div class="container segeo" style="margin-top: 7%;">


        <div class="row center-block well">

            <div class="col-sm-12">
                            <img class="img-circle loginFormPix" src="images/prof_photo.png" height="110" width="110"/>
                            <h2 class="text-center">ADD NEW CATEGORY</h2>
                            <?php if (isset($successREG)) { ?>
                            <div class="col-sm-4 col-sm-offset-4" style="color:#3facff;margin-bottom: 10px;"><?php echo $successREG; ?></div>
                        <?php } ?>
                    </div>
                <form action="#" method="POST">

                    <div class="form-group col-sm-4 col-sm-offset-4 col-xs-8 col-xs-offset-2">

                            <div class="input-group">
                                <span style="background:transparent;color:#333" class="input-group-addon"><i class="fa fa-pencil"></i></span>
                                <input style="height:40px" type="text" name="cat_name" id="cat_name" placeholder="Category name..." class="form-control inputFlat" required="" />
                            </div>
                            <br/>
                            <div class="input-group">

                                <textarea name="cat_desc" id="cat_desc" cols="50" rows="10" placeholder="Describe your category..." class="form-control inputFlat" required=""></textarea>
                            </div>
                            <br/>


                            <div class="input-group center-block" style="margin-top: 20px;">
                                <button type="reset" class="btn btn-sm btn-danger" name=""><i class="fa fa-arrow-left"></i>&nbsp;RESET</button>
                                <span><button type="submit" name="cat_submit" id="cat_submit" class="btn btn-sm btn-success pull-right">SUBMIT&nbsp;<i class="fa fa-arrow-right"></i></button></span>
                            </div>


                    </div>
                </form>   



                <div class="col-sm-4 pull-right">

                    <?php
                    //select category names and display

                     $sel = "SELECT cat_name FROM categories ORDER BY cat_id DESC";
                    $selcat = mysqli_query($conn, $sel);
                    if(mysqli_num_rows($selcat) > 0){
                         echo'<h3 class="text-muted text-uppercase text-center text-primary">Categories will be displayed Here...</h3>';
                        echo'<div class="table-responsive">';
                            echo'<table class="table table-striped">';
                               echo '<tr>';
                                    echo'<td style="font-weight: bold;">CATEGORY NAME</td>';
                                    echo'<td style="font-weight: bold;">ACTIONS</td>';
                                echo'</tr>';
                    while ($catROW = mysql_fetch_array($conn,$selcat)) { 

                                echo'<tr>';
                                    echo"<td>" .$catROW['cat_name']. "</td>";
                                    echo"<td></td>";
                                echo'</tr>';
                            echo'</table>';

                            }
                        }
                    ?>       
                </div>

            </div>

        </div>
</div>
    <script src="../js/bootstrap.min.js" type="text/javascript"></script>
    <script src="../js/jquery-2.2.3.js" type="text/javascript"></script>


    <script>
    $(document).ready(function(){
        $('#cat_name').click(function(){
            var name = $('#cat_name').val();
            var desc = $('#cat_desc').val();

            if($.trim(name && desc) !== ''){
                $.ajax({
                    url: "categories.php",
                    method: "POST",
                    data:{name:cat_name;},

                })
            }
        })
    })


    </script>

</body>
</html>

0 个答案:

没有答案