mysql_fetch_assoc()期望参数1是资源,给定数组 [英] mysql_fetch_assoc() expects parameter 1 to be resource, array given

查看:119
本文介绍了mysql_fetch_assoc()期望参数1是资源,给定数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的错误:mysql_fetch_assoc()期望参数1是资源,给定数组..





请帮助我。 .i无法从谷歌找到任何帮助..



我的代码:



This is my error : mysql_fetch_assoc() expects parameter 1 to be resource, array given..


Please help me..i cant find any help from google..

my code:

<?php

        //print_r($categories);exit;
         $current_cat = null;

        
        while($row = mysql_fetch_assoc($categories))
        {
        //print_r($row);exit;
        if ($row["title"] != $current_cat)
        {
        $current_cat = $row["title"];
          echo $current_cat; // course category name
        }
        else
        {
          echo $row["course_title"]; // course name 
        }
        } ?>







数组输出为:(print_r($ categories) ;退出;)



数组([0] =>数组([category_id] => 2 [title] =>甲板课程[course_title] => ;自适应转向)[1] =>数组([category_id] => 2 [title] =>甲板课程[course_title] =>测试对象2)[2] =>数组([category_id] => ; 2 [title] => Deck Courses [course_title] =>测试对象4)[3] =>数组([category_id] => 3 [title] => Engine Room Courses [course_title] =>测试对象3))




array output is :(print_r($categories);exit;)

Array ( [0] => Array ( [category_id] => 2 [title] => Deck Courses [course_title] => Adaptive Steering ) [1] => Array ( [category_id] => 2 [title] => Deck Courses [course_title] => Test subject 2 ) [2] => Array ( [category_id] => 2 [title] => Deck Courses [course_title] => Test subject 4 ) [3] => Array ( [category_id] => 3 [title] => Engine Room Courses [course_title] => Test subject 3 ) )

推荐答案

类别);退出;
categories);exit;


current_cat = null ;


while(
current_cat = null; while(


row = mysql_fetch_assoc(
row = mysql_fetch_assoc(


这篇关于mysql_fetch_assoc()期望参数1是资源,给定数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆