SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2004
    Location
    california
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looping problem in script

    need some help fixing this script. theres only 6 ucsd's string on that url page but when i run this script i get a looping list of ucsd's instead. i cant figure out whats wrong.

    PHP Code:


    <?php
        
    //set URL to fetch
        
    $URL "http://psy.ucsd.edu/~swh/adoptees.html";

        
    //open file
        
    $page fopen($URL"r");
        print(
    "uscd at $URL<br>\n");
        print(
    "<ul>\n");
        while(!
    feof($page))
        {
            
    //get a line
            
    $line fgets($page1024);

            
    //loop while there are still ucsd present
            
    while(eregi("ucsd"$line$match))
            {
                
    //print out URL
                
    print("<li>{$match[0]}</li>\n");
            }
        }
        print(
    "</ul>\n");
        
    fclose($page);
    ?>

  2. #2
    SitePoint Addict loadx's Avatar
    Join Date
    Jul 2004
    Location
    Melbourne, VIC, Australia
    Posts
    221
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is it your trying to do?

    that would help alot..because i don't see what your trying to accomplish.

    tah

  3. #3
    SitePoint Member
    Join Date
    Jun 2004
    Location
    california
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im just trying to extract the word "ucsd" from:

    http://psy.ucsd.edu/~swh/adoptees.html

    and print them out in a list. instead of 6 (how many there are on that web page) it loops and gives me an infinite amount. sorry, i should of put this in my earlier post.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think you need to test if $page is actually a valid file handle before entering your loop.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •