I keep getting this extra white-space when I load content from a mysql database into a textarea of a form. I've tried converting it into a string a then use the trim() function but I keep getting the same problem. Any ideas?
PHP Code:<?php
include "admin/conn/config.php";
include "admin/conn/connect_database.php";
$page_update = "";
if (isset($_POST['update'])){
$update = $_POST['update'];
$sql="UPDATE updates SET message='$_POST[update]', date=CURDATE()";
if (!mysql_query($sql,$opendb)){
die('Error: ' . mysql_error());
}
else {
$page_update = "<h2>Sidan har blivit uppdaterad!</h2>";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$result = mysql_query("SELECT * FROM updates ORDER BY date DESC LIMIT 1");
$row = mysql_fetch_array($result);
echo $row['message']." (".$row['date'].")";
echo $page_update;
?>
<form action="" id="" method="post">
<textarea cols="60" rows="10" name="update">
<?php
$result = mysql_query("SELECT * FROM updates");
$row = mysql_fetch_array($result);
$str = $row['message'];
echo trim($str);
?>
</textarea>
<br />
<input type="submit" value="Spara" class="krs-edit_align-r"/>
</form>
</body>
</html>


Reply With Quote
Bookmarks