0

How do you run a query like the following in PHP:

INSERT INTO table VALUES ('example name', 'thisisfirstline
           thisissecondline
           thisisthirdline')

I have type set to text.

I have no problems at all when I run it with Navicat. I tried running it in PHP:

mysql_query("INSERT INTO table VALUES ('example name', 'thisisfirstline
           thisissecondline
           thisisthirdline') 
           OR die('ERROR');

This outputs the following:

thisisfirstlinethisissecondlinethisisthirdline

How do I insert the value without sticking it all together?

1
  • Probably this new row in mysql has newline characters, but your client does not show them correct way. Try to use mysql console to be shure - what exactly is in database. Commented Feb 8, 2014 at 12:31

2 Answers 2

1

Put \n for inserting newline in a MySQL table :

INSERT INTO table VALUES ('example name', 'thisisfirstline\n
    thisissecondline\n
    thisisthirdline')
Sign up to request clarification or add additional context in comments.

Comments

0

make the type to varchar instead of text in table

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.