0

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;
}

Edited by pritaeas: Moved to PHP.

3
Contributors
2
Replies
13
Views
2 Years
Discussion Span
Last Post by rch1231
0

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){

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.