0 votes
in SoSci Survey (English) by s257376 (140 points)

Actually, a similar issue remains and I don't understand why. It's only on the third page (so the third choice of the discrete choice experiment), while the code is exactly the same on the previous two pages. This is the error message:

related to an answer for: Error message "replace"

1 Answer

0 votes
by SoSci Survey (327k points)

The second error message (the important one) says that you're using a variable $Attr2C, but do not define it.

I cannot see the PHP code above what's in the screenshot. But I guess that you have renamed the variable $Attr2A, $Attr2B, $Attr2C, but did not properly rename the variable at the beginning of the PHP code.

by s257376 (140 points)
Thank you for your reply. This is the PHP Code:

-------

$Attr2C = array(
1 => 'hotel',
2 => 'caravan',
3 => 'caravan',
4 => 'camping',
5 => 'caravan',
6 => 'hotel',
7 => 'caravan',
8 => 'caravan',
9 => 'caravan',
10 => 'hotel',
11 => 'caravan',
12 => 'hotel',
);

$code = value('DC07');
$TwoC = $Attr2C[$code];
replace ('%Attr2C%', $TwoC);

------

I cannot find the error...
by SoSci Survey (327k points)
Using that code, I cannot replicate the error message that is shown in your question above (no "undefined variable"). What does the debug information on the page say? Especially about DC07?
by s257376 (140 points)
The debug information on this page says the following:

------

[Information]    Interview number 155 is to be continued
[Information]    Questionnaire base from project sust_tourism will be used
[Information]    Retention period on page 9 has been 2 seconds
[Processing]    Reading answers from page 9
[Information]    Answer to DC02 = 3
[Information]    100% of the questions have been answered so far
[Processing]    Create page 10 in questionnaire base
[Content]    Show text Choice 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Information]    value("DC07") = 3
[Content]    Show text Note DCE
[Information]    The following placeholders have been prepared:
%Attr1A% = (text) walking / cycling
%Attr1B% = (text) walking / cycling
%Attr1C% = (text) public transportation
%Attr2A% = (text) camping
%Attr2B% = (text) caravan
%Attr2C% = (text) caravan
%Attr3A% = (text) 3 or more
%Attr3B% = (text) none
%Attr3C% = (text) 3 or more
%CostsA% = (text) 3,600
%CostsB% = (text) 3,600
%CostsC% = (text) 1,300

------
by s257376 (140 points)
Also the Discrete Choice Table on this page is shown normally and seemingly without error, just the error message is there.
by SoSci Survey (327k points)
It seems that there is much more code on the page that what you ahve posted. value('DC07') is there in a loop or used several times, I tink? It also seems that this part is setting %Attr2C% properly. So my gues would be that the error message comes from other code on page 10?
by s257376 (140 points)
I still don't know where the mistake was, but I coded the page again from scratch, and now it works. Thank you!

Willkommen im Online-Support von SoSci Survey.

Hier bekommen Sie schnelle und fundierte Antworten von anderen Projektleitern und direkt von SoSci Survey.

→ Eine Frage stellen


Welcome to the SoSci Survey online support.

Simply ask a question to quickly get answers from other professionals, and directly from SoSci Survey.

→ Ask a Question

...