<tops snipped>

At 04:00 PM 3/20/2006, you wrote:


I am using a PHP script to pull information from a FoxPro database via ODBC.
One of the fields is a memo field (large text) that contains newline
characters. Displaying this info to the web page is fine as the newlines are
ignored. The challenge is when I combine user entered text with the existing
info and try to update the database. It fails with an "unrecognized command"
because the end of field delimiter is on a different line. We're running on
PHP 4.2.7 and I have tried using various combinations of str_replace to
eliminate the newline characters, but I have been unsuccessful. Any
suggestions?

Giff

Giff Hammar
IT Director
Certified Parts Warehouse
http://www.certifiedparts.com <http://www.certifiedparts.com/>  <
<http://www.certifiedparts.com/> http://www.certifiedparts.com/>
mailto: [EMAIL PROTECTED]
V: 603.516.1707
F: 603.516.1702
M: 603.490.7163

Giff,

Are you inserting back into the FoxPro table? I had to use the following to clean up text, cut and pasted from WPfor Windows 5.2, into a textarea. Immediately before the INSERT I also used PHP's addslashes(). The database is MySQL.

        // have to clean up the extraneous CR/LF combos
        $trupara        = ".\r\n"; // period+CR+LF
        $dblquotpara    = '"'."\r\n"; // double quote+CR+LF
        $sglquotpara    = "'"."\r\n"; // single quote+CR+LF
        $questnpara     = "?\r\n"; // question+CR+LF
        $exclampara     = "!\r\n"; // exclamation+CR+LF
        $colonpara      = ":\r\n"; // exclamation+CR+LF
        $dudspc = ". \r\n"; // period+spc+CR+LF
        $flspara                = "\r\n"; //CR+LF
        $truflag                = "***"; //something unique

        $txtBody = str_replace ( $trupara, $truflag, $txtBody);
        $txtBody = str_replace ( $dblquotpara, "$$$", $txtBody);
        $txtBody = str_replace ( $sglquotpara, "%%%", $txtBody);
        $txtBody = str_replace ( $questnpara, "+++", $txtBody);
        $txtBody = str_replace ( $exclampara, "!!!", $txtBody);
        $txtBody = str_replace ( $colonpara, ":::", $txtBody);
        $txtBody = str_replace ( $dudspc, "###", $txtBody);

        $txtBody = str_replace ( $flspara, " ", $txtBody);
        $txtBody = str_replace ( $truflag, ".\n\n", $txtBody);
        ///double quote
        $txtBody = str_replace ( "$$$", '"\n', $txtBody);
        ///single quote
        $txtBody = str_replace ( "%%%", "'\n", $txtBody);
        ///question mark
        $txtBody = str_replace ( "+++", '?\n', $txtBody);
        ///exclamation mark
        $txtBody = str_replace ( "!!!", '!\n', $txtBody);
        ///colon
        $txtBody = str_replace ( ":::", ':\n', $txtBody);
        ///dudspace
        $txtBody = str_replace ( "###", '.\n\n', $txtBody);

        $txtBody = str_replace ( "\n ", "\n", $txtBody);

Hope this is helpful - Miles

PS Policy on this list is to bottom post.

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.385 / Virus Database: 268.2.5/284 - Release Date: 3/17/2006

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to