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 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2006
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Data from mySQL not showing fully in a textbox

    When i select data from a sql table and echo it, it echoes the full string in the field...but when i use it as a value in a textbox, it only displays the first word (nothing after the first space)

    maybe there is something wrong with my code

    PHP Code:

    ///connect.....

    $conn=mysql_connect($hostname,$username$password) or die ('Error connecting to mysql');
    mysql_select_db($dbname);


    $query  "SELECT * FROM songs WHERE id=".$Id;
    $result mysql_query($query);
    while(
    $row mysql_fetch_array($resultMYSQL_ASSOC))

    {
        echo 
    "<table width='200' border='0'>
      <tr>
        <td>NAME:</td>
        <td><input type='text' name='name' id='name' value={$row['name']} /></td>
      </tr>
      <tr>
        <td>ARTIST:</td>
        <td><input type='text' name='artist' id='artist' value="
    .$row['artist']." /></td>
      </tr>
      <tr>
        <td>URL:</td>
        <td><input type='text' width='215' name='url' id='url' value="
    .$row['url']." /></td>
      </tr>
      <tr>
        <td>IMGURL:</td>
        <td width='317'><input type='text' width='200' name='imgurl' id='imgurl' value="
    .$row['imageurl']." /></td>
      </tr>
      <tr>
        <td>DESC</td>
        <td><textarea name='desc' id=desc' rows='5' cols='50' value="
    .$row['desc']."></textarea></td>
      </tr>
    </table>"


  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,007
    Thanks
    2
    Thanked 311 Times in 303 Posts
    All parameters need quotes, more importantly when they are strings that contain spaces. Put some quotes around the outside of each of the value= parameters, for example on the first one in your code -
    Code:
    ...value='".$row['artist']."' /></td>
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • Users who have thanked CFMaBiSmAd for this post:

    Alphamonkey (08-26-2007)

  • #3
    New Coder
    Join Date
    Sep 2006
    Posts
    26
    Thanks
    3
    Thanked 0 Times in 0 Posts
    jesus, i knew it was something stupid like that lol

    thanks

  • #4
    New Coder
    Join Date
    Jul 2007
    Posts
    24
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Also, with textareas you may want to do...

    Code:
    <textarea name='desc' id=desc' rows='5' cols='50'><?php echo $row['desc']; ?></textarea>
    instead of

    Code:
    <textarea name='desc' id=desc' rows='5' cols='50' value=".$row['desc']."></textarea>


  •  

    Posting Permissions

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