dungareez Posted August 24, 2007 Share Posted August 24, 2007 Hi all, I keep having serious issues with using mysql_fetch_array($result) and I don't know why. I have used it many times previously without issue. Here is the code I am using (I have added in a few items while trying to debug it). function vendorReactivateList() { $query = "SELECT * FROM vendors"; $result = mysql_query($query) or die (mysql_error()); $num = mysql_num_rows($result);// used this to verify I was getting results (I am) $returnValue ="centercontent_____<font size=\"3\">Inactive Vendors</font><br /><br />"; // this is just part of the output while($row = mysql_fetch_array($result)); { $name = $row["name"]; $active = $row["active"]; $vID = $row["vendorID"]; if($active!=1)// am only doing this to simplify query for debugging, later this will be eliminated and query will be more specific { $returnValue .=$name." "; $returnValue .="<a href=\"#\" onclick=\"gensend('mode=9&vendorID=".$vID."&reactivate=vendor')\";>Reactivate</a><br />"; } } $returnValue .=$num; $returnValue .= mysql_result($result,0,'name');//used this to again verify I am getting an accessible result, I am. I can even iterate through this to bypass my problem with mysql_fetch_array , but I want to solve that problem as it has occurred to me in another spot as well return $returnValue ; } I swear I have looked at the syntax of the mysql_fetch_array syntax many times and can't see anything wrong. I am getting in the loop but it is not going through the array. I am seeing only one result without any values from the query (excluding my test with mysql_result($result,0,'name')). Any help would be very greatly appreciated as this issue is frustrating the heck out of me. I can get the exact functionality that I need by doing the following: // using this till I figure out my mysql_fetch_array issues $i =0; while($i < $num) { $name =mysql_result($result,$i,'name'); $vID =mysql_result($result,$i,'vendorID'); $active =mysql_result($result,$i,'active'); if($active !=1) { $returnValue .=$name." "; $returnValue .="<a href=\"#\" onclick=\"genSend('mode=9&vendorID=".$vID."&reactivate=vendor')\";>Reactivate</a><br />"; } $i++; But like I said I want to figure out exactly why mysql_fetch_array is not cutting it for me here while it is working fine in other areas. I can't see any difference in the code. Thanks Link to comment https://forums.phpfreaks.com/topic/66452-solved-mysql_fetch_array-either-me-or-it-going-crazy/ Share on other sites More sharing options...
btherl Posted August 24, 2007 Share Posted August 24, 2007 What do you see if you var_dump($row) at the top of your loop? Link to comment https://forums.phpfreaks.com/topic/66452-solved-mysql_fetch_array-either-me-or-it-going-crazy/#findComment-332807 Share on other sites More sharing options...
dungareez Posted August 24, 2007 Author Share Posted August 24, 2007 Thanks for the response btherl. When I do the var_dump I am getting bool(false) . I don't know why though? Link to comment https://forums.phpfreaks.com/topic/66452-solved-mysql_fetch_array-either-me-or-it-going-crazy/#findComment-333006 Share on other sites More sharing options...
dungareez Posted August 24, 2007 Author Share Posted August 24, 2007 solved, I had a semicolon after the while loop parameters while($row = mysql_fetch_array($result)); Link to comment https://forums.phpfreaks.com/topic/66452-solved-mysql_fetch_array-either-me-or-it-going-crazy/#findComment-333183 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.