Jump to content

Linebreaks in a post


Aftermath

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.

[code]
<?php
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);
    }


    mysql_close();

?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.