Jump to content


This topic is now archived and is closed to further replies.


Linebreaks in a post

Recommended Posts

** I commented the line:
[code]$entry = nl2br($entry);[/code]

out and when i changed it back it started working... Can php be picky like that?

Hello all. I have been working on a blog type site and I have encountered an issue. Whenever I try to create a post that has a line break in it, it says the data was succesful entered into the table but when I try to display it, it will only display text until the first linebreak.

I am unsure if this is a php or mysql problem, but the following code is my script to insert the info into the table.

if (isset($_POST['submit'])) {

    $title = htmlspecialchars(strip_tags($_POST['title']));
    $entry = $_POST['entry'];
    $username = $_POST['username'];

    $timestamp = strtotime($current_month . " " . $current_date . " " . $current_year);
    $entry = nl2br($entry);

    mysql_connect ('localhost', '******', '******');
    mysql_select_db ('******');

    $sql = "INSERT INTO post_table (timestamp,username,title,entry) VALUES ('$timestamp','$username','$title','$entry')";

    $result = mysql_query($sql) or print("Error!.<br />" . $sql . "<br />" . mysql_error());

    if ($result != false) {
        print "Your entry has successfully been entered!";
if (isset($_POST['edit'])) {
    $idnum = $_POST['idnum'];
header("Location:update.php?id=" . $idnum);



Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.