开发者

how to account for a newline in a mysql text field?

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

   mysql_query("select * from table where misc_note='he开发者_JAVA技巧llo\nworld'")

isn't working


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'.


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.


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: 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜