X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id C230DD1B4E3 for ; Mon, 13 Oct 2003 14:36:44 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14147-07 for ; Mon, 13 Oct 2003 11:35:59 -0300 (ADT) Received: from hosting.commandprompt.com (222.commandprompt.com [207.173.200.222]) by svr1.postgresql.org (Postfix) with ESMTP id 95196D1B505 for ; Mon, 13 Oct 2003 11:35:54 -0300 (ADT) Received: from commandprompt.com (dsl093-077-251.sea2.dsl.speakeasy.net [66.93.77.251]) (authenticated) by hosting.commandprompt.com (8.11.6/8.11.6) with ESMTP id h9DEZxA10859 for ; Mon, 13 Oct 2003 07:35:59 -0700 Message-ID: <3F8AB84E.8030008@commandprompt.com> Date: Mon, 13 Oct 2003 07:35:58 -0700 From: Robby Russell Organization: Command Prompt, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5b) Gecko/20030903 Thunderbird/0.2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-php@postgresql.org Subject: Re: newlines won't display in browser References: <2CCFF91A-FD21-11D7-A49D-00039308EB2C@sympatico.ca> In-Reply-To: <2CCFF91A-FD21-11D7-A49D-00039308EB2C@sympatico.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/16 X-Sequence-Number: 2377 Michael Hanna wrote: > Hi, > > hi, how do you put a newline in a TEXT data type? > > when inputting from a form into a textarea box..the return key creates a > newline, which is reflected in psql monitor but not when displaying the > page with php > > when I try inputting \n in the browser textarea form, they appear in the > webpage for some reason, in psql monitor, they appear as "\n" but also > make a newline > > Michael > I'd suggest doing this in your postgresql statement. Makes it easy when you use views and don't want to use php functions everywhere to do the task that postgresql can do for you. Perhaps plphp ? (since you know php) https://www.commandprompt.com/entry.lxp?lxpe=294 # Here is an example plphp function. CREATE OR REPLACE FUNCTION line_breaks(text) RETURNS text AS ' $txt = str_replace("\n","
\n",$arg0); if ($txt) { return $txt; } else { return $arg0; } ' LANGUAGE 'plphp'; Then on a select, I'd run SELECT id, line_breaks(textbox_field) as textbox_field FROM table; It would then replace all instances of \n with
\n. Cheers, Robby -- Robby Russell, | Sr. Administrator / Lead Programmer Command Prompt, Inc. | http://www.commandprompt.com rrussell@commandprompt.com | Telephone: (503) 222.2783