Log in

View Full Version : Php troubles



AlanAyazyam
12-13-2009, 04:42 AM
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. :mad:

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???? :confused:

traq
12-13-2009, 06:54 AM
try

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

AlanAyazyam
12-13-2009, 09:28 PM
Hmm...that didn't work for me. I'm getting the same error message.

traq
12-13-2009, 10:10 PM
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?

djr33
12-14-2009, 06:33 AM
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.

traq
12-14-2009, 08:47 PM
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
$strKeyword = $_GET['kw'];
header("Location: XXXX?tid=$strKeyword") ;
?> not
<?php $strKeyword = $_GET['kw']; header("Location: XXXX?tid=$strKeyword") ; ?>

AlanAyazyam
12-16-2009, 10:53 PM
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.

traq
12-17-2009, 01:02 AM
Notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm) :)