T_STRING error with pack function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mb2812@gmail.com

    T_STRING error with pack function

    I'm getting the T_STRING error ("Parse error: syntax error, unexpected
    T_STRING in alexa5.php on line 26") when using the pack function:

    function calculate_RFC21 04HMAC ($data, $key) {
    return base64_encode (
    pack ( "H*" , sha1((str_pad($ key, 64 , chr ( 0 x00))
    ( str_repeat ( chr ( 0 x5c), 64 ))) .
    pack ( "H*" , sha1((str_pad($ key, 64 , chr ( 0 x00))
    ( str_repeat ( chr ( 0 x36), 64 ))) . $data))))

    );

    }

    "Line 26" refers to line 3 above: "pack ("H....."

    I have no experience with pack, but the pack manual doesn't give me any
    clues as to the problem. I've commented out the pack stuff and replaced
    it with a print command to ensure it was this and not the previous line
    that is causing the problem.

    I've been working on this for several hours and have asked the best PHP
    friends I have, and have gotten no leads. Any hints from you guys would
    do wonders for my morale.

    You can see the full code here


    thank you, thank you, thank you

    matt

  • Oli Filth

    #2
    Re: T_STRING error with pack function

    mb2812@gmail.co m wrote:[color=blue]
    > I'm getting the T_STRING error ("Parse error: syntax error, unexpected
    > T_STRING in alexa5.php on line 26") when using the pack function:
    >
    > function calculate_RFC21 04HMAC ($data, $key) {
    > return base64_encode (
    > pack ( "H*" , sha1((str_pad($ key, 64 , chr ( 0 x00))
    > ( str_repeat ( chr ( 0 x5c), 64 ))) .
    > pack ( "H*" , sha1((str_pad($ key, 64 , chr ( 0 x00))
    > ( str_repeat ( chr ( 0 x36), 64 ))) . $data))))
    >
    > );
    >
    > }
    >
    > "Line 26" refers to line 3 above: "pack ("H....."
    >
    > I have no experience with pack, but the pack manual doesn't give me any
    > clues as to the problem. I've commented out the pack stuff and replaced
    > it with a print command to ensure it was this and not the previous line
    > that is causing the problem.[/color]

    It's nothing to do with the specific function - a parse error means
    that your basic PHP syntax is incorrect. Check your opening/closing
    brackets and comma separators on that line...

    --
    Oli

    Comment

    • mb2812@gmail.com

      #3
      Re: T_STRING error with pack function

      Right; I'd been poring over it trying to figure out where the error
      was. I found another copy of the code, and it's working now. I don't
      see any difference; maybe I had invisible characters in there or
      something.

      thanks for reading

      Comment

      Working...