Query seems to fail halfway with no error

Discussion in 'PHP' started by dave487, Dec 6, 2005.

  1. #1
    I have a page http://www.noblemarine.co.uk/clubfinder.php3 which selects the names of the clubs from a database.

    Refresh the page a few (<20) times and you will see the query fails at a particular point sometimes. This generates no error message so I can't see what the problem is.
    The query is:
    $query = "select name from clubs where name!='' order by name LIMIT 1500"; 
      
     $numresults=mysql_query($query);
     $numrows=mysql_num_rows($numresults);
    
     $result = mysql_query($query) or die("failed $query failed - . mysql_error()");
       
    
      while ($row= mysql_fetch_array($result)) {
    	  $name = trim($row[name]);
    	  $name2=$name;
    	  $str=$name;
    	  $length=25;
    	  $trailing='...';
    	  
    
          $length-=strlen($trailing);
          if (strlen($str) > $length) 
          {
             $name=substr($str,0,$length).$trailing;
          } 
          else 
          { 
             $name = $str; 
          }
      echo"<OPTION VALUE=\"$name2\">$name</OPTION>\n";
    PHP:

     
    dave487, Dec 6, 2005 IP
  2. virtualkev

    virtualkev Peon

    Messages:
    364
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    All seems ok to me.

    Why would you want to refresh a page 20 times?:confused:
     
    virtualkev, Dec 6, 2005 IP
  3. Matts

    Matts Berserker

    Messages:
    195
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    108
    #3
    I tried it 10 times and it was fine. Are you sending cache control headers? Maybe you're seeing a cached page when it was broken sometime in the past? Clear your browser cache and try again.
     
    Matts, Dec 6, 2005 IP
  4. dave487

    dave487 Peon

    Messages:
    701
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It showed a broken page once so I refreshed the page until it did it again which occurred after 20 clicks.
     
    dave487, Dec 6, 2005 IP
  5. philej

    philej Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    This is probably your browser or webserver responding to the odd condition of 20 refreshes in a row.
     
    philej, Dec 6, 2005 IP
  6. palespyder

    palespyder Psycho Ninja

    Messages:
    1,254
    Likes Received:
    98
    Best Answers:
    0
    Trophy Points:
    168
    #6
    In your query try changing the

    name!=''
    PHP:
    to

    name<>''
    PHP:
    Thats what works on my server but it may or may not work on yours.
     
    palespyder, Dec 6, 2005 IP