1

I have created a HTML template where in html block I have pasted html code and then used the social block to create the footer. Now I am using AMPscript variable

%%[
Var @Email, @fname, @sname,
Set @Email = Email
Set @fname = First name
Set @sname = Second name
]%% 

and used First Name: %%= v(@fname) =%% Last Name:%%= v(@sname) =%% in the html.

But its showing this error enter image description here

New contributor
ANSHIKA SINGH is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2

AMPScript has a problem with your variable values First name and Last Name because of the space they contain.

Generally, try to avoid fields with spaces for this needless error.

If not an option, you can wrap those values in square brackets so they still get interpreted.

The most important thing to be learned here is: Read the error messages, they point you exactly to this problem, you can see at the end of each message how the space cuts the variable name after the first word.

this should work:

%%[
Var @Email, @fname, @sname,
Set @Email = Email
Set @fname = [First name]
Set @sname = [Second name]
]%% 

Also, when referencing those variables, don't use spaces:

wrong: %%= v(@fname) =%% right: %%=v(@fname)=%%

Hope this helps!

2

I believe it's a good, defensive coding practice to wrap your personalization strings in AttributeValue() and then validate them with the Empty() function.

I do this in all of the emails I build.

%%[

Var @Email, @fname, @sname,
Set @Email = AttributeValue("Email")
Set @fname = AttributeValue("First name")
Set @sname = AttributeValue("Second name")

if empty(@Email) then
   raiseError("missing email", 1)
endif

]%%
%%=v(@fname)=%% %%=v(@sname)=%%

Doing this has the added benefit of handling send context attributes with spaces.

#TeamNoNakedPersonalizationStrings

Your Answer

ANSHIKA SINGH is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.