topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:50 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: In search of ... a way to kill tabs  (Read 4573 times)

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,294
    • View Profile
    • Donate to Member
In search of ... a way to kill tabs
« on: August 16, 2011, 10:41 PM »
OK, this one seems a bit stupid ... I seem to do a lot of those, don't I :(?

I'm in process of rebuilding a box that crashed.  Part of that rebuilding involves rewriting segments of PHP code that were lost.  Mostly, that's going well, but there's one problem that seems unresolvable. 

This script uses MySQL as part of the record keeping.  But whenever I try to populate an HTML textarea from a text column in the tables, it's always prefaced by either five (5) or six (6) tab characters.  None of the trim() functions are effective.  I can find many Google references to adding tabbing capability, but none, so far, to eradicating them.  I've checked - and rebuilt - the tables with several different versions of MySQL, even tried different versions of PHP.  The PHP SQL is simple -

Code: PHP [Select]
  1. select NoteContent from notes where NoteKey=n
  2. $notes=trim($notes)
  3. insert into notes (NoteContent) values (\$note\")
  4. or
  5. update notes set NoteContent=\"$note\" where NoteKey=n
I left out some of the script, the if/then/else structures, but what's there is the relevant stuff.  The textarea bit is just
<... type=textarea ...><php? echo $note ?></textarea>
But every time, the textarea shows the text with leading tabs, tabs that do not exist in the table's text field.  Oh, yeah, it's not browser-specific.  I've tried FF 3.x, FF 6, IE9, Safari, Opera, all with the same result.  These tabs are pulling my cork - something that seems easily accomplished, lately -and I've run out of places to look for an answer, save for DC.

Anybody got any ideas?

hamradio

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 825
  • Amateur Radio Guy
    • View Profile
    • HamRadioUSA.net
    • Read more about this member.
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #1 on: August 16, 2011, 10:58 PM »
Should $notes=trim($notes) be $note=trim($note);?

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,294
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #2 on: August 16, 2011, 11:34 PM »
Yeah ... I was ad-libbing that, not copy-and-pasting.  Way too much code to paste, anyway.  However, the actual PHP is correct in terms of spelling - one of my favorite errors is typos or a missing ),}," or ;, so I keep a list of all vars in a separate document, and compare frequently.  However, typos won't account for the prefacing tabs in three (3) textarea constructs.  For what it's worth, I've had a friend check my code, and she doesn't find anything erroneous - apart from a few of the aforementioned typos  :P

Due to time constraints, I'm trying not to rewrite this thing from scratch, have mostly succeeded, save for this one problem.

hamradio

  • Charter Honorary Member
  • Joined in 2006
  • ***
  • Posts: 825
  • Amateur Radio Guy
    • View Profile
    • HamRadioUSA.net
    • Read more about this member.
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #3 on: August 16, 2011, 11:43 PM »
Could maybe try...

$note = str_replace("\t","",$note);

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,294
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #4 on: August 17, 2011, 01:24 AM »
OK, I had tried
$studentnote=trim($studentnote,"\t")
without success, both with and without the "\t" element.  When I tried
$studentnote=str_replace("\t","",$studentnote)
I lost the note altogether, although the tabs were still there  >:(.

I think I've tried every replacement function in the PHP docs, w/o success  :mad:.

As Yul Brynner once said, "Is a puzzlement."

justice

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,898
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #5 on: August 17, 2011, 04:25 AM »
#1
Replace <php? echo $note ?>
with
<?php echo $note; ?>

#2
if you replace it with <?php echo "";?> are the tabs still there?

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #6 on: August 17, 2011, 07:03 AM »
Just out curiosity...(given that you've already tried the most common correct answers)... Have you considered that something later in the code could be putting the tabs back in?

I've gotten had by that one once or twice.

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #7 on: August 17, 2011, 07:20 AM »
Have you seen/tried this one?

http://stackoverflow...hin-variables-in-php

barney

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 1,294
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #8 on: August 17, 2011, 10:52 AM »
Hm-m-m ... I don't thimk anything is throwing tabs in before storing the note, but I'll have another look.

And that still wouldn't 'splain why trim() & ltrim() aren't doing their job after I extract the note. 

Is there some character, maybe Unicode, that represents a tab w/o actually being a tab?  Or, perhaps, a textarea [HTML] configuration that automatically prefixes content?  Yeah, I know, that's reaching, but when logic fails, sometimes the illogical will work  :P.

Oh, on the typos:  I'm typing this in on the fly, not pasting from the actual code - that's why there are so many missing ; and such.  However, using several different IDEs - Komodo, CodeLobster for PHP, Rapid PHP 2010 - for testing purposes assures me that there are no typos in the code.  (I just wish one of those IDEs would let me step through the code.  CodeLobster has a start on that, but ...)

One other thing ... this seemingly applies only to the textarea element.  Just did a quick test on a type="text" element - no tabs.  In hindsight, I shoulda done that long ago, but then hindsight is always so much better  :tellme:.  Oh, and one text area on this page always prefixes six (6) tabs, the other five (5) tabs  :(.  And this seems to happen only on one page.  (I'm going through the include() files now to see if anything there might be a cause.)

Stoic Joker

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 6,646
    • View Profile
    • Donate to Member
Re: In search of ... a way to kill tabs
« Reply #9 on: August 17, 2011, 11:42 AM »
Is there some character, maybe Unicode, that represents a tab w/o actually being a tab?  Or, perhaps, a textarea [HTML] configuration that automatically prefixes content?  Yeah, I know, that's reaching, but when logic fails, sometimes the illogical will work  :P.

A string of spaces will leave a gap in the output, but tabs don't seem to work that way:
Code: HTML [Select]
  1. <textarea rows="2" name="S1" cols="20">     food</textarea>

I too resort to illogic at times.