CodeIgniter Forums
Problem with new line! - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Problem with new line! (/showthread.php?tid=19958)



Problem with new line! - El Forum - 06-23-2009

[eluser]juan1904[/eluser]
Hi,

I'm trying to insert two different variables into my database like this:
Quote:$text1 = 'blah blah..';
$text2 = 'mhm mhm!';
$text = $text1 . '\n' . $text2;

$this->db->insert('my_table', array('text' => $text));
I want that \n to represent a new line in the text, but when it's still just text. Do you get my problem?


Problem with new line! - El Forum - 06-23-2009

[eluser]tonanbarbarian[/eluser]
this is a fundamental PHP issue.
it has to do with the different between strings using double quotes " and single quotes '
You should go and research this in the PHP docs.
briefly you have to use double quotes " for \n and other such special characters
single quote string ' are not passed in any way and are displayed EXACTLY as entered