Jump to content


Photo

Linebreaks in a post


  • Please log in to reply
No replies to this topic

#1 Aftermath

Aftermath
  • Members
  • PipPip
  • Member
  • 14 posts

Posted 18 May 2006 - 08:50 PM

** I commented the line:
$entry = nl2br($entry);

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.

<?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();

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users