0
<?php

/*
Xbox Live Gamertag Checker
Written by Sedulous
*/

if ($argc < 2) 
{
    print "Usage: php $argv[0] <input file> <output file>\n";
    exit;
}

$input_fd = fopen($argv[1], 'r');
$output_fd = fopen($argv[2], 'w');

while (!feof($input_fd)) 
{
    $current_gamertag = fread($input_fd, filesize($input_fd));
    $current_test_page = file_get_contents("https://live.xbox.com/en-US/Profile?gamertag=" + $current_gamertag);
    if (strpos($current_test_page, "Ooops! What happened to this page?" !== false))
    {
        fwrite($output_fd, $current_gamertag, strlen($current_gamertag));
    {
}

fclose($input_fd);
fclose($output_fd);

?>

This script is meant to be ran in the command-line/terminal for various reasons.

Whenever I try to run it, I get the following error: "PHP Parse error: syntax error, unexpected end of file in /home/jared/Desktop/gamertag_checker.php on line 31"

I don't see any errors, does anyone know how to fix this?

1
  • That means parentheses or braces don't match. Your IDE should help you find the mismatch. Commented Jan 11, 2014 at 18:45

3 Answers 3

3

Change

if (strpos($current_test_page, "Ooops! What happened to this page?" !== false))
    {
        fwrite($output_fd, $current_gamertag, strlen($current_gamertag));
    {

to

if (strpos($current_test_page, "Ooops! What happened to this page?" !== false))
    {
        fwrite($output_fd, $current_gamertag, strlen($current_gamertag));
    }
Sign up to request clarification or add additional context in comments.

2 Comments

I see no difference between the original and "fixed" versions?
In original { was added in after the if .. which should be }
2
if (strpos($current_test_page, "Ooops! What happened to this page?" !== false))
{
    fwrite($output_fd, $current_gamertag, strlen($current_gamertag));
{

That last one is supposed to be a }. What do you use for programming? I suggest a proper editor, NetBeans. Or, if you want something more simple, go with Notepad++ or Sublime Text 2 or 3.

2 Comments

@Sedulous,if you knew why you post question here?
He didn't know where it was, but he could have guessed it was a simple one. As a lot of errors usually are. Silly mistakes overlooked upon so easily.
0

your strpos call is wrong:

yours:     if (strpos($current_test_page, "Ooops! What happened to this page?" !== false))
should be: if (strpos($current_test_page, "Ooops! What happened to this page?") !== false)
                                                                              ^---here

Note the location change of the ) at the end. You're doing a strpos against the boolean true/false result of the `"Oops" is strictly not false" comparison, instead of a "result of strpos is not strictly false".

This is also wrong:

$current_test_page = file_get_contents("[..snip..]Profile?gamertag=" + $current_gamertag);
                                                                     ^---

+ in PHP is mathematical addition. You want ., which is string concatenation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.