Jump to content

[SOLVED] mysql_fetch_array(), either me or it going crazy?


dungareez

Recommended Posts

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.