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 11 of 11
  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    input value being cut off where spaces exist

    My address record being queried is '555 Disney Lane"

    echo($address1) ;
    ===============
    This display 555 Disney Lane



    echo("<br><input name='address' value=" .$address1.">" ) ;
    ==========================================
    This displays 555


    Somehow the spaces in the record don't show up in an input field???


    Any help would be greatly appreciated.

    Thanks,
    Andrea

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Do you have that field set to datatype varchar? What length is the field? Have you verified through some other means that the entire address is actually stored in the table? Use phpMyAdmin if you have it to check the value.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    What language is this written in?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    was written in php.

    Believe me...it is in the dbase and the length is 200 varchar. like I said it prints correctly outside on an input field.

    This shows correctly 555 Disney Lane
    echo($row[address]) ;

    This cuts off the address to 555
    echo("<br><input name='address' value=" .$row[address].">" ) ;


    All the other fields are populating such as first name, last name. There are no spaces in them like the address field.

    The spaces are somehow affecting the input field value. I think it has something to do with the array and how it is parsing. I think it is parsing each record looking for a space???

    Hell. I don't know...I'm new at php...Cold fusion and ASP are so much easier...ARGGGG


    Any response would be wonderful.

    Thanks,
    Andrea

  • #5
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is the code..hope it shows up here..

    $result = @mysql_query("Select * from customers where id=99999");
    if (!$result) {
    echo("<p>Error in query: " .mysql_error(). "</p>");
    exit();
    }
    if ($row = mysql_fetch_array($result))
    {

    echo($row[address]) ;
    echo("<br><input name='address' value=" .$row[address].">" ) ;

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Ok out of curiosity try it like this:

    <input name="address" value="<?php echo $row["address"]; ?>">

    This is also a little quicker to render as the php engine doesn't have to print out the entire html string. When you have many of these it the time it takes to parse everything starts adding up. Typically it's best to only print exactly what you need to print hence the ability to jump in and out of php mode.
    Last edited by Spookster; 09-13-2002 at 01:15 PM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    echo("<br><input name='address' value=" .$row[address].">" ) ;

    let's have a think about what is echoed there
    ...value=555 Disney Lane

    You see, because there are NO quotes around the html output of the value, the browser cannot understand anything beyond 555. The rest would still be echoed into the source code, it just wouldn't show.
    I always tend to echo out strings encased in single quotes, so that double quotes are shown in the html

    echo '<br><input name="address" value="'.$row["address"].'">';
    would yield
    ...value="555 Disney Lane"

    which html would accept.

    I hope that explains it properly for you.

    Edit: Spookster's version would also output quotes into the html and would also work
    Last edited by Ökii; 09-13-2002 at 11:24 AM.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Good eye Okii. I didn't notice the missing quotes. Without the quotes the php engine is printing out integers as it should hence the 555. With quotes the engine prints out the string as it should hence the entire address.
    Last edited by Spookster; 09-13-2002 at 01:18 PM.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #9
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well guys it was late and plus I'm a newbie...so I'm sure this is the answer. I will test later on today and let ya know.

    Thanks A MILLION !!!

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We were all newbies once - one day you'll be the one to answer some other newbies question.

    PS - kudos on the attractive model whose images adorn your signature link.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #11
    New Coder
    Join Date
    Sep 2002
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okii


    Those photos are me...Andrea. My hubby is a photographer...so he took some photos of me and my sweety pie doggie. Isn't he so sweet!!

    Thanks for the compliment though.

    Cheers
    Andrea


  •  

    Posting Permissions

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