944,198 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 844
  • PHP RSS
Oct 30th, 2009
0

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

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Folaju is offline Offline
7 posts
since Oct 2009
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
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.
Sponsor
Featured Poster
Reputation Points: 557
Solved Threads: 734
Bite my shiny metal ass!
pritaeas is offline Offline
4,207 posts
since Jul 2006
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
I have tested the query in phpmyadmin and it pulls back the expected results. so it not working in the code is beyond me
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Folaju is offline Offline
7 posts
since Oct 2009
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
Click to Expand / Collapse  Quote originally posted by Folaju ...
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).
Sponsor
Featured Poster
Reputation Points: 557
Solved Threads: 734
Bite my shiny metal ass!
pritaeas is offline Offline
4,207 posts
since Jul 2006
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
Click to Expand / Collapse  Quote originally posted by Folaju ...
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.
Reputation Points: 28
Solved Threads: 37
Junior Poster
kekkaishi is offline Offline
164 posts
since Oct 2009
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Folaju is offline Offline
7 posts
since Oct 2009
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
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.
Sponsor
Featured Poster
Reputation Points: 557
Solved Threads: 734
Bite my shiny metal ass!
pritaeas is offline Offline
4,207 posts
since Jul 2006
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
Click to Expand / Collapse  Quote originally posted by Folaju ...
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
Reputation Points: 28
Solved Threads: 37
Junior Poster
kekkaishi is offline Offline
164 posts
since Oct 2009
Oct 30th, 2009
0
Re: Warning: mysql_fetch_array() & Warning: mysql_free_result() errors
Click to Expand / Collapse  Quote originally posted by pritaeas ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Folaju is offline Offline
7 posts
since Oct 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: how do i delete a directory with php?
Next Thread in PHP Forum Timeline: Delete Function Problem...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC