Unexpected T_String

Discussion in 'PHP' started by dragons5, Sep 10, 2008.

  1. #1
    I just can't figure this out. I keep getting 'Unexpected T_String on line 3' but it looks fine to me. Oddly enough when I remove Line 1 completely I get a different error "Unexpected T_Function on line 4"

    ini_set('memory_limit', '99999M');
    function createUrl($url,$lastnum) {
        $find = "?";
        $trim = rtrim ($url,'a..z,A..Z,=,_,&');
        $remove_to = strpbrk($trim, '?');
        $number = 1;
        $counter= 0;
        while ($lastnum != $number) {
            $over = "?page=".$number."&";
            $replace = str_replace($find,$over,$url);
            $myArray[$counter] = $replace;
            $number++;
            $counter++;
        }
        return $myArray;
    }
    
    PHP:

     
    dragons5, Sep 10, 2008 IP
  2. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #2
    That's probably where your problem is. The ";" doesn't belong there.
     
    LogicFlux, Sep 10, 2008 IP
  3. dragons5

    dragons5 Well-Known Member

    Messages:
    2,940
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    115
    #3
    thanks. that wasnt the right code.. someone was trying to help me and added that in. code updated in original post:

    ini_set('memory_limit', '99999M');
    function createUrl($url,$lastnum) {
        $find = "?";
        $trim = rtrim ($url,'a..z,A..Z,=,_,&');
        $remove_to = strpbrk($trim, '?');
        $number = 1;
        $counter= 0;
        while ($lastnum != $number) {
            $over = "?page=".$number."&";
            $replace = str_replace($find,$over,$url);
            $myArray[$counter] = $replace;
            $number++;
            $counter++;
        }
        return $myArray;
    }
    
    PHP:
     
    dragons5, Sep 10, 2008 IP
  4. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I pasted the new code as is into a file, saved it and ran it from the command line with the -l (syntax check) option and got this:

    C:\>php -l c:\temp\t_string_error.php
    No syntax errors detected in c:\temp\t_string_error.php


    So I don't know what the problem is.
     
    LogicFlux, Sep 10, 2008 IP
  5. dragons5

    dragons5 Well-Known Member

    Messages:
    2,940
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    115
    #5
    its odd when i comment out line one the error changes to 'Unexpected T_Function in line 4'
     
    dragons5, Sep 10, 2008 IP
  6. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I ran that syntax check using php 5.2.5 .
     
    LogicFlux, Sep 10, 2008 IP
  7. LogicFlux

    LogicFlux Peon

    Messages:
    2,925
    Likes Received:
    102
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Try putting just that code in its own file and run it separately and see if you still have the problem.
     
    LogicFlux, Sep 10, 2008 IP
  8. nice.wallpapers

    nice.wallpapers Active Member

    Messages:
    142
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Hi,

    I also tested that , above code is not showing up any error i think may be error is in some other file.

    Thanks,
     
    nice.wallpapers, Sep 10, 2008 IP
  9. dragons5

    dragons5 Well-Known Member

    Messages:
    2,940
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    115
    #9
    i got it fixed.

    thanks anyways guys.

    :D
     
    dragons5, Sep 11, 2008 IP