Larry Vollmer
asked on
Syntax problem?
I have this chunk of code:
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])]/[-MA ILINGID-]/ newsletter /[-LIST_ID -]
I am thinking the problem may be fixed with something like this:
But that seems to break my local. the page won't load. Is there something wrong with my syntax?
<?php
if (empty($unsub)) {
$unsub = $this->Html->url(array(
'controller' => 'things',
'action' => 'unsubscribe',
"[\$base64([\$address])]",
"[-MAILINGID-]"
), true);
$unsub = rawurldecode($unsub);
} ?>
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])]/[-MA
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);
} ?>
But that seems to break my local. the page won't load. Is there something wrong with my syntax?
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
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 ?
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.
Roads - that solution also renders a not found page.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
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?
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
THanks to all for feedback, a combination of everyone's responses led me in the right direction, so points awarded to all.