tags:

views:

39

answers:

3

what's the proper syntax to account for a newline in "text" field? for example,

   mysql_query("select * from table where misc_note='hello\nworld'")

isn't working

A: 

You are probably outputting it to text field and not in textarea. Only textarea can display new lines.

If \n is still not working you can try \r\n.

knagode
\n\r dont work, it's \r\n in windows or \n in unix
Imre L
True. I corrected my answer.
knagode
+1  A: 

If you want mysql way then: char(10) or char(13),char(10) depending if u want \n or \r\n

mysql_query("select * from table where misc_note=concat('hello',char(13),char(10),'world')")

EDIT: however it seems you may need this instead:

mysql_query("select * from table where misc_note like 'searchstring%'")

% indicates any number of any character that can occur, means you search for all notes startig with 'searhstring'.

Imre L
A: 

There is a PHP Constant, PHP_EOL, which holds the End Of Line character specific to the system.

More information on this can be found at: http://stackoverflow.com/questions/128560/when-do-i-use-the-php-constant-php-eol

Not really sure if this would help you in your certain situation, but yea, just throwing it out there.

Brad F Jacobs