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 10 of 10
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Post Php return value wrong

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes'] ."</span>"; } ?>" >
        </TEXTAREA>
    Gives this as answer:
    !--No Profile Info has been set yet--!</span>">

    Instead of this:
    !--No Profile Info has been set yet--!

    Any ideas?
    Last edited by Shinon; 02-21-2010 at 05:04 AM.

  • #2
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    This is because your "> is outside of the false parenthesis..

    Try..

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
        </TEXTAREA>

  • #3
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by Taylor_1978 View Post
    This is because your "> is outside of the false parenthesis..

    Try..

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
        </TEXTAREA>
    Not working, same result.

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes'] ."</span>"; } ?>" >
        </TEXTAREA>
    I changed my code above to the point I am on, one </span> was missing.
    But still same wrong result

  • #4
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Take a look at my code again.. I think you may have copied it before I edited it as I made an error too...

    You have " > at the end of yours, just before </TEXTAREA> that should not be there.

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
        </TEXTAREA>

  • #5
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question

    Quote Originally Posted by Taylor_1978 View Post
    Take a look at my code again.. I think you may have copied it before I edited it as I made an error too...

    You have " > at the end of yours, just before </TEXTAREA> that should not be there.

    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style=\"color:blue;\">!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style=\"color:blue;\">" .$row['notes']. "</span>"; } ?>
        </TEXTAREA>
    Yeah the " is for closing the value=" in the end
    and the > is for closing the textarea properties.

    Also tried what u suggested and it still gives this:
    !--No Profile Info has been set yet--!</span>

    Also if the spans are removed, then it gives no output...
    HELP i am stuck here 2 hours
    Last edited by Shinon; 02-21-2010 at 05:32 AM.

  • #6
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    UGH! My apologies... Sorry for wasting time with replies and not looking at it correctly.

    Let's take out your PHP code and look at it purely in HTML:

    Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<span style="color:blue;">!--No Profile Info has been set yet--!</span>">
        </TEXTAREA>
    Here is your issue... You are enclosing quotes inside quotes...

    The HTML is seeing "span style=" as the VALUE property.

    Instead of using doubles quotes try single...


    PHP Code:
    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php if ($row['notes'] == ""){echo "<span style='color:blue;'>!--No Profile Info has been set yet--!</span>";}
                     else{echo 
    "<span style='color:blue;'>" .$row['notes']. "</span>"; } ?>
        </TEXTAREA>

  • #7
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I tried simple quotes twice till now.

    Make the example easier for fixing.

    PHP Code:
    <?php if ($row['notes'] == "")
         {
         
    $value='<span style="color:blue;">!--No Profile Info has been set yet--!</span>';
         }
         else
         {
         
    $value="<span style=\"color:blue;\">" .$row['notes'] ." </span>";
         }
    ?>

        <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile"
        value="<?php echo $value ?>">
        </TEXTAREA>
    But still same results.
    Am i missing something?

    Result:
    !--No Profile Info has been set yet--!</span>">

    Also the simple inline quotes u suggested give no result, return nothing back.
    Last edited by Shinon; 02-21-2010 at 05:49 AM.

  • #8
    Regular Coder
    Join Date
    Jun 2003
    Location
    Australia
    Posts
    528
    Thanks
    8
    Thanked 8 Times in 8 Posts
    Putting $value='<span style="color:blue;">!--No Profile Info has been set yet--!</span>'; makes no difference...

    As the end result will still be: value="<span style="color:blue;">!--No Profile Info has been set yet--!</span>">

    Try this:

    PHP Code:
    <?php if ($row['notes'] == "")
         {
         
    $value="<span style='color:blue;'>!--No Profile Info has been set yet--!</span>";
         }
         else
         {
         
    $value="<span style='color:blue;'>" .$row['notes'] ." </span>";
         }
    ?>

        <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" class="profile" id="profile">
    <?php echo $value?>
        </TEXTAREA>
    Get rid of the VALUE altogether..

    Oh and you were missing a semi-colon in '$value ?>'

  • Users who have thanked Taylor_1978 for this post:

    Shinon (02-21-2010)

  • #9
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Thumbs up

    Found the problem.

    PHP Code:
    <?php if ($row['notes'] == "")
         {
         
    $value="!--No Profile Info has been set yet--!";
         }
         else
         {
         
    $value=$row['notes'];
         }
    ?>

    <TEXTAREA style="margin-left:20px; color:blue;"name="profile" rows="10", cols="70" 
    class="profile" id="profile">
    <?php echo $value?></TEXTAREA>
    Textarea fields work differently from other input types.
    U cannot set value, but rather initialize it after the TextArea properties.
    No <span> etc are rendered also, but appear as plain text.

    We learn something new everyday it seems
    Thanks a lot Taylor btw
    Last edited by Shinon; 02-21-2010 at 05:59 AM.

  • #10
    New Coder
    Join Date
    Feb 2010
    Posts
    15
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Seems we found the answer at the same time
    A thank you flag for you then ^^


  •  

    Posting Permissions

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