Link to home
Create AccountLog in
Avatar of Larry Vollmer
Larry Vollmer

asked on

Syntax problem?

I have this chunk of code:

<?php
if (empty($unsub)) {

	$unsub = $this->Html->url(array(
		'controller' => 'things',
		'action' => 'unsubscribe',
		"[\$base64([\$address])]",
		"[-MAILINGID-]"
	), true);

	$unsub = rawurldecode($unsub);

} ?>

Open in new window


Basically, it is supposed to build a link so that a user can unsubscribe from an email but it does not do that correctly. This is what it builds:

http://mysite.com/unsubscribe/[$base64([$address])]/[-MAILINGID-]/newsletter/[-LIST_ID-]

I am thinking the problem may be fixed with something like this:
<?php
if (empty($unsub)) {

	$unsub = $this->Html->url(array(
		'controller' => 'things',
		'action' => 'unsubscribe',
		"[" . base64($address) . "]",
		"[-MAILINGID-]"
	), true);

	$unsub = rawurldecode($unsub);

} ?>

Open in new window


But that seems to break my local. the page won't load. Is there something wrong with my syntax?
SOLUTION
Avatar of SStory
SStory
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Where did you get this piece of code from ?
Avatar of Larry Vollmer
Larry Vollmer

ASKER

It's an internal intranet app - I am trying to get more info so I can be more help for you guys.

Roads - that solution also renders a not found page.
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Slick - that is correct - those options are replaced with actual values that eventually lead to a user unsubscribing from an email list.
OK, I have seen this sort of parser replacement of place holders in all sorts PHP "one size fits all" set-ups, but you do not say what the $this->Html->url( ) function-method does? Surely you have the code for that function-method, since you show us the code from the CLASS that uses the Html CLASS which has that method, I would think that the url( ) method is the one that uses the array input to to put values into [-MAILINGID-]  and  [-LIST_ID-], it seems to place 'unsubscribe' into the [-ACTION-] placeholder ?
Can you show us the code for the $this->Html->url( ) method?  I do not have any info to give any more help?
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
THanks to all for feedback, a combination of everyone's responses led me in the right direction, so points awarded to all.