Hi I’ve just developed a php page that gets texts from a mysql database and displays them on the site, but my problem is that it doesn’t show the paragraphs I make. The texts are uploaded to the database with a form. Can anyone help me?
Can you post the code you are refering to? Do you mean that the data is not in the mysql database, or the data is not making it back to the site from the database?
First thing to check: are you sure that you're converting your newline characters to '<br />'s? You're possibly just printing the string out and HTML is ignoring your new lines...
Simular to TwistMyArm When adding information to a database, new lines should be shown using "\n" (which you can not see, but there will be a new line) What you need to do on echo is a little function function ShowStr($str){ $str = stripslashes($str); $str = str_replace("\n","<br>",$str); return $str; } Then everytime you echo a Blog from the mysql, just use that function name
You can also use PHP's nl2br() function You do this when your inserting the content into your database, something like below... <?php $var = $_POST['textarea_name']; $var = nl2br($var); //Your MySQL queries here ?> Code (markup): More information on this function http://ca.php.net/manual/en/function.nl2br.php
True, I am in a habit or creating my own functions. Couple of Tips Never insert HTM code into a MySQL DB and always, always run mysql_real_escape_string BEFORE adding anything to your database.
Something else, I love php Find out Everyones Location I am es.php.net (Yes i know you can change it in the options)