Textarea to MySQL adds tab

When saving the contents of a textarea to MySQL into a blob field using PDO I get 6 tabs added to the beginning of the data and 4 tabs added to the end (that is tabs as in if you pressed the TAB key)
Is there something special I should be doing for a textarea?
This is a just a normal prepare statement followed by execute(array etc and assigning the post value of the textarea to a value for the prepare statement.
':description' => $_POST['description']

The posted data does not contain the tabs - I checked by echoing out the post value.
LVL 58
GaryAsked:
Who is Participating?
 
GaryConnect With a Mentor Author Commented:
Found the problem - there were tabs before and after <?=$description?> which were being added into the textarea.  

Stupid I know...
0
 
Ray PaseurCommented:
Uhh, not sure but have you tried trim() right before preparing the data element?
0
 
Dave BaldwinFixer of ProblemsCommented:
Echoing the data in HTML is misleading because HTML ignores tabs and other control characters.  It may display them as a space.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
GaryAuthor Commented:
Already tried trim to no effect
@Dave
But in an editor they still should show - which they don't...
0
 
mcnuteCommented:
Have you tried this:

$text = preg_replace("/\s+/", " ", $text);  

Open in new window


Where $text is your $_POST['description']; variable
0
 
Ray PaseurCommented:
If trim($_POST['description']) did not do the job, then I think we need to see a little more deeply into the problem.  Can you determine exactly when the addition of the tabs occurs?  For example, if you use phpMyAdmin to examine the data base do you detect the tabs in the column?  If you change the column type to TEXT does the problem still present?  Can you produce the SSCCE so we can install a parallel script and try it on our servers?
0
 
Dave BaldwinFixer of ProblemsCommented:
Glad you found it.
0
 
GaryAuthor Commented:
Realised my own stupidity
0
All Courses

From novice to tech pro — start learning today.