hi i keep getting this error on my php page

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/internal/public_html/includes/xpage_admin.php on line 871

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/internal/public_html/includes/xpage_admin.php on line 877

the code below works perfectly on my test server and error checking is on.

this is the code below

$result = $this->db->ExecuteSql ("Select w.*, c.primary_name, a.keyname From {$this->object} w LEFT JOIN `smp_customers` c ON w.client_name=c.customer_id LEFT JOIN `smp_accesspoint` a ON w.accesspoint_type=a.keyid Order By {$this->orderBy} {$this->orderDir}" , true);
            while ($row = $this->db->FetchInArray ($result)) line 871
            {
                $client_name = $row['client_name'];
                $id = $row['wireless_id'];
                $ssid_1 = $row['ssid_1'];
                $ssid_2 = $row['ssid_2'];
                $ssid_3 = $row['ssid_3'];
                $ssid_4 = $row['ssid_4'];
                $ssid_password_1 = $row['ssid_password_1'];
                $ssid_password_2 = $row['ssid_password_2'];
                $ssid_password_3 = $row['ssid_password_3'];
                $ssid_password_4 = $row['ssid_password_4'];
        $accesspoint_type = $row['accesspoint_type'];
                $edit_link = "<a href='{$this->pageUrl}?ocd=edit&id=$id'><img src='./images/edit.gif' alt='Edit' /></a>";
                $del_link = "<a href='{$this->pageUrl}?ocd=del&id=$id' onClick=\"return confirm ('Do you really want to delete this Wireless SSID?');\"><img src='./images/trash.gif' alt='Delete' /></a>";
                $bgcolor = ($bgcolor == "#EEEEEE") ? "#FFFFFF" : "#EEEEEE";

                $this->data ['TABLE_ROW'][] = array (
                    "ROW_CLIENT" => ($client_name == 0) ? "&nbsp;" : "<a href=clients.php?ocd=search&search_field=customer_id&search_info=".$row['client_name'].">".$row['primary_name']."</a>",
                    "ROW_SSID1" => ($ssid_1 == "") ? "&nbsp;" : $ssid_1,
                    "ROW_SSID2" => ($ssid_2 == "") ? "&nbsp;" : $ssid_2,
                    "ROW_SSID3" => ($ssid_3 == "") ? "&nbsp;" : $ssid_3,
                    "ROW_SSID4" => ($ssid_4 == "") ? "&nbsp;" : $ssid_4,
                    "ROW_SSID_PASSWD1" => ($ssid_password_1 == "") ? "&nbsp;" : $ssid_password_1,
                    "ROW_SSID_PASSWD2" => ($ssid_password_2 == "") ? "&nbsp;" : $ssid_password_2,
                    "ROW_SSID_PASSWD3" => ($ssid_password_3 == "") ? "&nbsp;" : $ssid_password_3,
                    "ROW_SSID_PASSWD4" => ($ssid_password_4 == "") ? "&nbsp;" : $ssid_password_4,
            "ROW_ACCESSPOINT_TYPE" => ($accesspoint_type == "") ? "&nbsp;" : "<a href=accesspoint.php?ocd=search&search_field=keyid&search_info=".$row['accesspoint_type'].">".$row['keyname']."</a>",
                    "ROW_EDITLINK" => $edit_link,
                    "ROW_DELLINK" => $del_link,
                    "ROW_BGCOLOR" => $bgcolor
                );
            }
            $this->db->FreeSqlResult ($result); //877

these are the functions in line 871 and 877

function FetchInArray ($result)
{
    return mysql_fetch_array ($result);
}

//--------------------------------------------------------------------------
function FreeSqlResult ($result)
{
    mysql_free_result ($result);
}

Any help is appreciated

What happens when the query fails, and $result is false, instead of a resource ? My guess is that there is an error in the query or it's not connecting correctly.

I have tested the query in phpmyadmin and it pulls back the expected results. so it not working in the code is beyond me

I have tested the query in phpmyadmin and it pulls back the expected results. so it not working in the code is beyond me

Check if the connection to the database is successful (in code).

I have tested the query in phpmyadmin and it pulls back the expected results. so it not working in the code is beyond me

If the connection is OK then try this.
u said its workin on the test server, so can u recheck the database in ur server and confirm if the tables and column names are exactly the same as ur db in the test server. remember, mysql is case sensitive.

I dont think the Db connection is the issue as other pages used the same connection and the have to issues. just this new page

Then it must be this new page, something has to be missing, if all others work.

Before the while, add: die(mysql_error()); to see if and why the query fails.

I dont think the Db connection is the issue as other pages used the same connection and the have to issues. just this new page

so y dont u give the necessary tables a check out :)

Then it must be this new page, something has to be missing, if all others work.

Before the while, add: die(mysql_error()); to see if and why the query fails.

Fixed it, using the die(mysql_error()); found their was an issue with Order By {$this->orderBy} {$this->orderDir} that it was pulling in the wrong field name. i explicit ordered it by the right field and it fixed it

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.