Warning: mysql_fetch_array() & Warning: mysql_free_result() errors

Thread Solved

Join Date: Oct 2009
Posts: 6
Reputation: Folaju is an unknown quantity at this point 
Solved Threads: 0
Folaju Folaju is offline Offline
Newbie Poster

Warning: mysql_fetch_array() & Warning: mysql_free_result() errors

 
0
  #1
Oct 30th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 867
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 140
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #2
Oct 30th, 2009
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.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Folaju is an unknown quantity at this point 
Solved Threads: 0
Folaju Folaju is offline Offline
Newbie Poster
 
0
  #3
Oct 30th, 2009
I have tested the query in phpmyadmin and it pulls back the expected results. so it not working in the code is beyond me
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 867
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 140
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #4
Oct 30th, 2009
Originally Posted by Folaju View Post
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).
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 35
Reputation: kekkaishi is an unknown quantity at this point 
Solved Threads: 5
kekkaishi kekkaishi is offline Offline
Light Poster
 
0
  #5
Oct 30th, 2009
Originally Posted by Folaju View Post
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.
Last edited by kekkaishi; Oct 30th, 2009 at 7:53 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Folaju is an unknown quantity at this point 
Solved Threads: 0
Folaju Folaju is offline Offline
Newbie Poster
 
0
  #6
Oct 30th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 867
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 140
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
0
  #7
Oct 30th, 2009
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.
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 35
Reputation: kekkaishi is an unknown quantity at this point 
Solved Threads: 5
kekkaishi kekkaishi is offline Offline
Light Poster
 
0
  #8
Oct 30th, 2009
Originally Posted by Folaju View Post
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 6
Reputation: Folaju is an unknown quantity at this point 
Solved Threads: 0
Folaju Folaju is offline Offline
Newbie Poster
 
0
  #9
Oct 30th, 2009
Originally Posted by pritaeas View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the PHP Forum
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC