Page 1 of 1

Echo PHP character spaces from MySQL

Posted: Fri May 07, 2010 10:31 am
by sleepydad
I am inserting data into MySQL using:

Code: Select all

$query="insert into `` values ('','','')";
$result=$db->query($query);
Works fine. Is some instances, the data that I'm entering will have odd character spaces ie:

hello
  wo

 r
  l
   d

I've designated the row for this in MySQL to be TEXT, and when the record is added it shows exactly as I've demonstrated when viewing in phpmyadmin. When I echo it out using:

Code: Select all

echo $row[''];
... my output is all flush left. I've tried str_replace('',' ',$string), but that didn't work. I've tried inserting the record using htmlspecialchars - didn't work. I've echoed using nl2br - nope.

Suggestions??

Thanks -
sleepydad

Re: Echo PHP character spaces from MySQL

Posted: Fri May 07, 2010 7:34 pm
by Christopher
It seems like something in your code is converting spaces to the meta character   This is probably done for outputting in HTML, but should not be done for the database.