Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post

    Porblem with "gluing" variables together in if statement..

    I'm about to pull my hair out here..

    PHP Code:
    while ($textpc <= $textlp) {

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

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

    exit();

        }

    $textpc++;


    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!!

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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} == "") {
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #3
    Regular Coder
    Join Date
    Apr 2004
    Posts
    684
    Thanks
    24
    Thanked 1 Time in 1 Post
    Your psychic powers worked!

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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 == "") {
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •