Results 1 to 8 of 8

Thread: Php troubles

  1. #1
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Php troubles

    I am having a heck of time with this PHP crap! I'm trying to redirect a link to my clickbank affiliate code, and at the same time insert a tracking code.

    XXXX=affiliate id

    <?php $strKeyword = $_GET['kw']; header("Location: XXXX?tid=". $strKeyword ) ; ?>

    Then, to insert the id, I would type:

    www.site.com/folder/offer.php?kw=TRACKING ID

    ANYWHO! This is so weird because it totally worked for one of my links. But now I can't recreate it! That one link works but even when I use the EXACT SAME code in a similar situation it doesn't work.

    Now it sends me an error saying that is an unexpected T_VARIABLE. Which is great, but I don't know which one it is or how to fix it! And if it's truly wrong, why would it work the other time. Why would it work once for one thing and then not work for the exact same situation another time????

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    try
    PHP Code:
    <?php $strKeyword $_GET['kw']; header("Location: XXXX?tid=$strKeyword") ; ?>
    works for me

  3. #3
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hmm...that didn't work for me. I'm getting the same error message.

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    what line are you getting the error message on? and is it the same line as this code?

    "unexpected t_variable" means that a $variable is somewhere it shouldn't be, usually because of a missing semicolon or quote. double-check your entire script for typos.

    header() can be a little difficult sometimes, too. what version of php are you running?

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You must be missing a required element of syntax. Line numbers are usually accurate within 2-4 lines of the problem (usually exact but with syntax errors can get off by a line or two when a semicolon is missing).
    If you need to debug further, strategically disable code sections with /*comments*/ to find the problem area.
    You are looking for a missing or duplicated quote, bracket, semicolon or parthesis, probably.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    try *only* those two lines (without the rest of your script) to see if it really is this part that is causing the error.

    another recommendation (if you're not doing so already) is to put each line of code actually on a different line so it's easier to find the problems:
    PHP Code:
    <?php 
    $strKeyword 
    $_GET['kw']; 
    header("Location: XXXX?tid=$strKeyword") ;
    ?>
    not
    PHP Code:
    <?php $strKeyword $_GET['kw']; header("Location: XXXX?tid=$strKeyword") ; ?>

  7. #7
    Join Date
    Dec 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Okay, I got it resolved. The problem was I think I was trying to do the editing in a word processor, and while it worked one time, it didn't work after that. So I am doing the editing in Coda now and it's working.

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

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
  •