I am trying to insert a line separator to options of profile_fields table.

$sql = "INSERT INTO {profile_fields}(title, name, category, type, weight, required, register, visibility, options) values ('%s','%s','%s', '%s', '%d', '%d', '%d', '%d', '%s')";
db_query($sql, 'country', 'profile_vm_Country','personalinfo','selection',10,0,1,2,'US\r\nUK\r\nFrance');

Unfortunately,
The value of options is not

US
UK
France

but

US\r\nUK\r\nFrance

Any help will be appreciated!

Comments

da_solver’s picture

Hi,
Are you rendering the data in html? http://www.w3.org/TR/html401/struct/text.html

drupaul.z’s picture

Thanks for your reply.

I want to init some profile fields of user register page.
I have a country profile field, I do not want to add countries in web admin page.
I want to add those countries in my module, so I want to write some code in .install file to insert them to database
Unfortunately, It does not work, '\r\n' and '
' are all escaped by db_query.

I still can not insert them into data with newline character.

kvvnn’s picture

Replace 'US\r\nUK\r\nFrance' with 'US' . "\n" . 'UK' . "\n" . 'France' , and it should create line breaks for you.

You need double quotes for the \n, as "single quotes are as is".

Thanks to hefox on #drupal IRC.

Benone_’s picture

That one worked for me. Thanks!