faqts : Computers : Programming : Languages : PHP : Database Backed Sites : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

16 of 72 people (22%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

How do you Insert strings with new-line characters (Enter-key in textarea) with a SQL string? (Access, ODBC)

Oct 22nd, 2001 15:19
Onno Benschop, Matt Gregory, Andrew Rutter, http://www.php.net/manual/en/ref.strings.php


Ask yourself what you are going to be doing with the information.  If 
the blob data will most likely be used by PHP then use the addcslashes 
to put the data into the database.
Otherwise, use the other string functions to convert the newlines into 
<br> tags and pump them in.
Your solution really depends on your use.  You might have to replace 
some character escapes with SQL specific identifiers as well.
Some functions you may find handy are:
string htmlspecialchars (string string [, int quote_style])
string quotemeta (string str)
string nl2br (string string)