Hi Guys I am beginner in PHP i am getting Warning: mysql_fetch_array(): Eror... anybody help me

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/kksivash/public_html/drngpit/student-portal/admin/model.php on line 76

function get_deptbyID($id=""){
    $sql = "SELECT * FROM department where id = ".$id;
    $result = mysql_query($sql);
    $row = mysql_fetch_array($result);
    while ($row = mysql_fetch_array($result, MYSQL_NUM))
    return $row;
}

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/kksivash/public_html/drngpit/student-portal/admin/model.php on line 138

function get_semID($id="",$year=""){
    $sql = "SELECT sid,sname,year,did FROM semester where did =".$id." ORDER BY sname ASC" ;
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)){
        $res[] = $row;
    }
    if(isset($res))
        return $res;
    else
        return 0;
}

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home4/kksivash/public_html/drngpit/student-portal/admin/model.php on line 151

function get_internalID($id=""){
    $sql = "SELECT no_internals FROM department where id =".$id."" ;
    $result = mysql_query($sql);
    while($row = mysql_fetch_array($result)){
        $res[] = $row;
    }
    if(isset($res))
        return $res;
    else
        return 0;
}

Recommended Answers

All 2 Replies

There was a problem executing your query. Did you connect to your database?

You are setting id="" which means that no value is supplied for the query. It is like running this:

SELECT no_internals FROM department where id =

You need to either remove the where clause or supply a value to test the value of id against.

What I think you need to do is to change the function call first line to:

function get_deptbyID($id){

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.