String concatanation help plz

Hai folks

sorry foks, i can’t post this code here. page cannot display or somthing occurs.
not sure why. so i took a screen shot.

the above code is not working :frowning:

writing one lang inside another…

1 get the target string working first.

Create a mini page with the html/JS working in tandem with a real value eg a pid of 1.

Look at the source code of the mini page which works.

2 get PHP to output the code which matches the source code in a mini page

ie substitute the number 1 with a PHP var (as simple as declaring $pid = 1; at the top of this mini page).

Plug your code back into your main page, and bingo, it works or it doesn’t work, so you look at the source code again, and if it is truly correctly formed, then you likely have a JS problem, so you get out your DOM inspector and start grilling that.

That is how you chase down problems with writing JS using PHP, till you learn to always start with working JS and build up to getting PHP to create it for you. Works for me anyhow…

Look closer at your string - why are you closing the double quotes before echoing the pid?


echo 'window.location.href="login.php?source=ad-extend-activation.php?pid=[COLOR="Red"]"[/COLOR]'.$pid.'";';

the value of source should also probably be URLEncoded, since it contains ?

thanks for the valubale tips!
sure, here after when print js code through php, ill take a look at the source code to see how it has represented :slight_smile:

hmm, i am confused when to separate a variable from other strings and when not :rolleyes:

So exactly what does the target string which actually works, with a real value for pid look like?