View Full Version : Data from mySQL not showing fully in a textbox

08-25-2007, 05:50 PM
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


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

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

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

08-25-2007, 06:28 PM
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 -

...value='".$row['artist']."' /></td>

08-26-2007, 01:22 AM
jesus, i knew it was something stupid like that lol


08-27-2007, 06:09 AM
Also, with textareas you may want to do...

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

instead of

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