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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2005
    Location
    Paraguay
    Posts
    36
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Error displaying data in a <input> tag

    Hi all;

    I'm experiencing a very extrange problem and I wonder if somebody can explain me what is going on:

    I have a mysql table with the data of my clients, one of the fields is of course, 'name'. In this field, the admin stores the name and surnames of each client.

    The HTML form works perfectly when you are typing in the data for the first time. The information is saved correctly into the database. If I want to print the name field, in a HTML form, it also shows as it is in the table, but the problem arise when I try to display the value in a 'input type' field, causing that what is displayed is all the content of the field BEFORE the first space character.

    For instance:

    stored value in the table: the blue cat
    if I print it in a HTML form: the blue cat
    if I try to display the value in a HTML form using input type= the

    Below is an example in php:

    PHP Code:
    function show_form_user($user)
    {

    $name=$user['nomape'];

    //this works:
     echo '<table width=80%><tr>';
     echo '<tr><td><li><b>Name and Surname:</b></td>';
     echo '<td>'.$user['nomape'];
     echo '</td></tr></table>

    // this is not working:

    ?>
     <form name=form_reg method=post action="upd_user.php" onsubmit="return check_reg2();">
     <table border=0>
     <tr>
         <td>Name and Surname:</td>
         <td><input type=text name=nomape size=30 maxlenght=30 value=<? echo $nomape;?>>
         </td></tr>
    </table>
    <?
    }

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You should be getting a parsing error if that is your exact code. You don't have a '; after the last echo in your function.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Quotes

    Also, this is one of those occasions where you'll probably need to have your attribute value quoted--apart from the fact that it's good practice to do so, anyway (if you're using an XHTML doctype it's even mandatory):
    Code:
    <input type="text" name="nomape" size="30" maxlenght="30" value="<? echo $nomape;?>">
    Regards,
    Ronald.
    ronaldvanderwijden.com


  •  

    Posting Permissions

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