View Full Version : Porblem with "gluing" variables together in if statement..

05-16-2004, 01:13 AM
I'm about to pull my hair out here..

while ($textpc <= $textlp) {

if ($fmtextq . $textpc == "") {

echo "Please make sure all questions are filled in before submitting. Thanks!";





Ok, I can not pull the correct value in that if statement.... I can get the value to print out correctly if I echo it; but I can't get it working in that if statement.... any help here? I've been trying several different things over the last hour or more & I'm about to pull my hair out!! :mad:

05-16-2004, 01:51 AM
maybe tell us what you are trying to do instead of yet another cryptic post with some strange code ...

using my psychic powers, i think you're looking for

if (${'fmtextq' . $textpc} == "") {

05-16-2004, 12:06 PM
Your psychic powers worked! ;)

05-16-2004, 10:43 PM
What can i say ...

It's actualy rather hard to find in the manual. Especially if the first part of the variablename needs to be some fixed text where you then glue the valu from a variable to. I found it out initially by just experimenting with all possible syntaxpossebilitys.

Most coders would use
$varname = 'fmtextq' . $textpc
if ($$varname == "") {