Jump to content

query sometimes returns ghost data


zathrus

Recommended Posts

I haven\'t been able to find this answer on the web, so here\'s what\'s happening.

 

A fairly simple php script is calling a mysql database, and putting the results into an array.

 

This database stores information on products, so there may be multiple rows with the same name, but they\'ll have a different topic type (category) and they all have a unique id of course.

 

Here\'s a chunk from the file (this script calls another database, and generates links to information in that database)

 


while($row = mysql_fetch_row($topic_result))

{ 

//row[0]=Topic_id

$test = $row[0];

$items++;

$topic_types_query = "SELECT Name, `Order` FROM `Topic_Types` WHERE Topic_Type = \'$test\'";

$topic_type_result = mysql_query($topic_types_query);

$topic_type_row = mysql_fetch_array($topic_type_result);



     $link_list[] = array(\'order\' => $topic_type_row[1],

         \'id\' => $row_id[0],

                           \'type\' => $row[0],

                      \'type_name\' => $topic_type_row[0]);



}



$counter=0;

$items +=5;  //shouldn\'t have to do this, but if I don\'t add at least one to

//this value, 1 less result gets printed, than there should be, in all cases

while($counter <= $items)

{

  $i=0;

  while($i <= $items)

  {

     if ($link_list[$i][\'order\'] == $counter)

{

//print $items;

print $link_list[$i][`order`];

           $info_box_contents[] = array(\'text\' => "<tr><td><a href=http://somewebsite.com/Topics/somefile.cgi?ZType=" . $link_list[$i][type] . "&ZID=" . $link_list[$i][id] . ">" . $link_list[$i][\'type_name\'] . "</a></td></tr>");

}

$i++;

  }



  $counter++;

}

 

(some of the values used come from further up)

 

So, the results are simply

 

some link

another link

another link (as many as there is information in the database on that item)

 

However with 2 items specifically, you get

some link

<-- blank line

some link

another link

etc

 

Anyone know where this ghost data is originating from?

(that is my entire question)

 

I\'ve also tried checking if the elements are empty before I print but mysql didn\'t agree with me on that.

 

Thanks in advance, Jonathan.

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.