Re: Retrieving query from MSSQL Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, April 28, 2005 5:51 am, Mike Smith said:
> On 4/28/05, Richard Lynch <ceo@xxxxxxxxx> wrote:
>> I'm betting dollars to doughnuts that you've got a newline at the end of
>> $sql1 which is messing you up.
>
> You're right! Give that man a doughnut! When I tested the query in
> Query Analyzer. I hit [Enter] to format the query and make it
> readable, then copy-and-paste into the form. I have tried:
>
> str_replace("\n","",$sql1);
> and
> preg_replace("\n","",$sql1);
>
> to pull the new line out plus a few other variations. Those failed.
> I'll keep at, but any pointers are always appreciated.

If you are on a Mac, you'll have a "\r" in there as well.

Plus, some day, you might WANT to have a newline in your data, like:

UPDATE foo SET contents = "War\nand\nPeace"

What is probably safest is:
$sql1 = trim($sql1);

This strips off any whitespace before/after the query, which should not
affect any valid query, but will get rid of bogus newlines at the end.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux