SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi:

    I found similar posts using "search", but nothing quite answered my question: I have two form fields, one a text field and the other a textarea field. The values are stored in a MySQL database exactly as they are entered. But when I use PHP to display them, the one that originated from the text field contains only the first word. That is, anything after the first space, if there is one, gets lost, even though I can see it in the database record. The one that originated from the textarea field, however, is fine.

    For now, I'm converting spaces to underscores from the text field input, and I suppose it would be just as easy to convert them back to spaces when PHP is going to display the values. However, I'm guessing there's probably a better way to deal with this problem. Can anyone help? Thanks!

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Phil-man where are you trying to display the data in another text field? Chances are you don't have "" around the value attribute. This would cause only the first word to appear, but in textarea it would not matter. So look for

    <input type="text" name="name" value=This is the value>

    Should be

    <input type="text" name="name" value="This is the value">
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually it's in two places. One is in a text field, and you're right, I can see where the problem is with that, i.e. no quotes. Easy fix. However, the second is just plain old text. It's part of a link as follows:

    echo("<li><p><a href=\"../directory/" . $Location . "\">" . $Name . "</a> (by " . $username . ")<br>\n");

    I can see that the value of $Name, as it appears in the database, is "This is a test." And yet all that appears as a result of the above line is "This".

    In contrast, the results of the following line...

    echo("Comments: " . $Comments . "\n");

    where the value in the database is "This is a test.", the output is also "This is a test." I can't understand the difference between these two...

    Thanks.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Phil can you show the code that assigns the value from the database to $Name
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    SitePoint Addict Phil-man's Avatar
    Join Date
    Nov 2000
    Posts
    291
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops... never mind. I found the problem: the problem is that I'm an idiot! There isn't a problem in the code. There was an intermediate step in which the information was resubmitted to the database from the text field that displayed only the first word... and we now know why THAT happened (thank you). So, the information went into the database correctly, then was displayed wrong in a text field, and was then resubmitted to the database incorrectly. That's why it appeared wrong in the plain text. Had I gone back and checked the database record AGAIN, I would have seen that, but I only looked at it right after the original database addition was made. Either way, it would have taken me a lot longer to figure out if you hadn't suggested I look at the text field. Thanks again.

    If I had a brain I'd be dangerous.


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
  •