SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 32
  1. #1
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP+ mysql values being clipped inside textbox?

    Hi. I'm experiencing this very annoying problem. I'm reading information from the database and then putting these variable values inside form textboxes. But when it shows up inside the textbox it's not the full text, it's clipped. The textboxes look like this:

    <input type='text' name='pic1' size='20' maxlength='28' value='$thevalue'>

    What am I doing wrong? I would really appreciate some help please

    Thanks a million!

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    What is the text you should see, and what is the text you see?
    What is the content of $thevalue (do an echo).
    Post the code.

  3. #3
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When I do the echo it reads the full text and everything that should be inside the variable. It's only when it reads inside the textbox that it clips it.

  4. #4
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    What is the text you should see, and what is the text you see?
    What is the content of $thevalue (do an echo).
    Post the code.
    You have set the max lenght to the text. try to remove it
    Power of Knowledge

  5. #5
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think the maxlength should be affecting it as the value of the $thevalue is shorter than 28 characters.

  6. #6
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Why don't you answer my questions? Just by looking at that piece of pseudo code you posted I won't be able to understand what's the problem.

  7. #7
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Yes, post your code!

    If you echo the variable outside a textarea - what does it give you?
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  8. #8
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I echo my code it works perfectly. It's only inside the textbox that it gets clipped.

    The code to get the info from my DB is:

    $get_user = "select * from users WHERE username = '$_COOKIE[user]' ";
    $get_user_res = mysql_query($get_user) or die (mysql_error());

    $user_fname = stripslashes(mysql_result($get_user_res,0,'fname'));
    $user_lname = stripslashes(mysql_result($get_user_res,0,'lname'));
    $quote = stripslashes(mysql_result($get_user_res,0,'quote'));

    And then I have my textbox code I mentioned above.

    For example I have the quote that reads: the price of greatness is responsibility. and thats being put as the value inside this textbox code

    <input type='text' name='quote' size='26' maxlength=41 value='$quote'>

    If I echo then it reads everything but inside the textbox it only reads it as: the price of

  9. #9
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    <input type='text' name='quote' size='26' maxlength=41 value='$quote'>
    This is not your actual code. It would show $quote in the textbox.

  10. #10
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no this is my actual code. This is all being shown inside a PHP document inside an echo.

  11. #11
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,496
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by csj View Post
    no this is my actual code. This is all being shown inside a PHP document inside an echo.
    So the code is

    echo "<input type='text' name='quote' size='26' maxlength=41 value='$quote'>";

    Anyway, if you echo just before this line and it shows you the correct value, then you might try lmasi's suggestion and take off the maxlength and/or size parameter. Just to see if it makes a difference.

  12. #12
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes that's correct. Sorry for not being clear. Thanks for all your help. I really appreciate your time


    If I take the maxlength off it still doesn't work. I really dont understand why this is happening.

  13. #13
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi
    would you pls provide example you put in $qoute, and what is is being output in the text box.
    $quote = " hey print this data data";
    echo "<input type='text' name='quote' size='23' maxlength=1 value='$quote'>"
    i suspect the size of the text box cannot accomodate the data in the $qoute variable.
    Power of Knowledge

  14. #14
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    change size='23' to size='100' to see if it is there or not
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  15. #15
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by csj View Post
    Hi. I'm experiencing this very annoying problem. I'm reading information from the database and then putting these variable values inside form textboxes. But when it shows up inside the textbox it's not the full text, it's clipped. The textboxes look like this:

    <input type='text' name='pic1' size='20' maxlength='28' value='$thevalue'>

    What am I doing wrong? I would really appreciate some help please

    Thanks a million!
    Is the text less than 20 characters? You don't just have a maxlength set you have a size set. It won't display anything past 20 characters. Also, why are you using stripslashes on database output. That should never be necessary.
    Visit my blog
    PHP && Life
    for technology articles and musings.

  16. #16
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's still not showing up even though I made the size larger. So weird.

  17. #17
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see now that it's showing up fine inside IE, it's only in Firefox that it's not working. Why is this?

  18. #18
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sometimes if you have certain characters in the textbox it wont show up correctly.

    And given that you are outputting a quote to the textbox makes me think that this might be teh case. Try putting htmlentities() around the $quote and see what happens.

    If not... can you give us an example of some text that doesn't work properly?

  19. #19
    SitePoint Addict lmasi02's Avatar
    Join Date
    Aug 2004
    Location
    Zambia
    Posts
    257
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    great that it wrked with ie
    Power of Knowledge

  20. #20
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is the output not entity encoded?
    Visit my blog
    PHP && Life
    for technology articles and musings.

  21. #21
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how do you use htmlentities()?

  22. #22
    hi galen's Avatar
    Join Date
    Jan 2006
    Location
    New Haven, CT
    Posts
    1,228
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  23. #23
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Look at the manual - that's what it's there for: http://uk.php.net/htmlentities.

    What's the HTML sourcecode generated for the textarea?
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  24. #24
    SitePoint Addict csj's Avatar
    Join Date
    Mar 2005
    Location
    South Africa
    Posts
    202
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    when I look at the source code it shows the full, correct value. It's only not showing inside the textbox

  25. #25
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any output, that is in any way derived from user input, should be run through htmlspecialchars() if only for security reasons. In this situation it also ensures proper display of values.
    Visit my blog
    PHP && Life
    for technology articles and musings.


Bookmarks

Posting Permissions

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