Reply to Re: [PHP] Retrieving query from MSSQL Table

Your name:

Reply:


Posted by Richard Lynch on 04/29/05 03:43

On Thu, April 28, 2005 5:51 am, Mike Smith said:
> On 4/28/05, Richard Lynch <ceo@l-i-e.com> 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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация