I know nothing about PHP, which is why I come here. Any help would be appreciated. What I want to do is:

Have a PHP script automatically go to http://users.ign.com/about/Tal-IGN (fopen?), for example, and pull out the number next to "Total # Posts" (692,472) and save it as a variable that I could then manipulate and display (reg exp?).

Please any help quickly, thanks very much.

    Ugly as sin, but this type of thing ususally is:

    <?PHP
    $file = file_get_contents('http://users.ign.com/about/Tal-IGN');
    preg_match('/Total&nbsp;#&nbsp;Posts:(?:.*?)(?:<td[^>]*>)([\\d,]*?) /s', $file, $matches);
    $num_posts = $matches[1];
    echo $num_posts;
    ?>

      Thanks so much! Except when I preview it I get:

      ]>)([\d,]?) /s', $file, $matches); $num_posts = $matches[1]; echo $num_posts; ?>

      even if i add in cheap basic html. Why is that displaying instead of just the number?

      Sorry bout bothering you for free help.

        Are you sure you copied it out exactly as it is? I just tried the code again, and it's working fine.

          edit: Nevermind, installation problems, thanks alot!

            You bet. Glad it's working.

              One more question:

              If I have an HTML form in another html file with the target of that php file, and a text field that's name is "name", shouldn't this return the number for the url with that name at the end? I just get blank.

              <?PHP
              $file = file_get_contents('http://users.ign.com/about/$name');
              preg_match('/Total&nbsp;#&nbsp;Posts๐Ÿ™?:.?)(?:<td[>]>)([\d,]*?) /s', $file, $matches);
              $num_posts = $matches[1];
              echo $num_posts;
              ?>

              Thanks again.

              EDIT: will that only work if register globals is on?

              EDIT: Got it to recognize with import_request_variables but I still don't know how to incorporate it into the "file_get_contents('http://users.ign.com/about/$name');" line.

              Please help? :p

                Try one of these:

                file_get_contents('http://users.ign.com/about/'.$name);
                file_get_contents("http://users.ign.com/about/$name");

                PHP doesn't interpolate the string for variables if it is in a single quote. It will with a double quote.

                Also, yes, it will only work with register_globals set to on, as it looks like you have it. Try this (assuming your are using the post method with the form)

                $name = $_POST['name'];

                  AAAAAAACK one final question. I'm sorry to keep asking.

                  Ideally, I'd like to have a text area in my form and seperate the values into variables by the "/n" in between each value. Is this very difficult? Sortof the same idea as finding that on the web page but in a string?

                    Write a Reply...