I'm trying to create a discussion forum using PHP. I have declared a post table for different posts with attributes(columns) such as id and content.
Content is of type "LONGTEXT", collation "latin1_swedish_ci"
This was on the database part.
Now the PHP coding is as follows
if(!$_SESSION['signed_in'])
{
echo 'You must be signed in to post a reply.';
}
else
{
//a real user posted a real reply
$sql = "INSERT INTO
posts(post_content,
post_date,
post_topic,
post_by)
VALUES ('" . $_POST['reply-content'] . "',
NOW(),
" . Mysql_real_escape_string($_GET['id']) . ",
" . $_SESSION['user_id'] . ")";
$result = mysql_query($sql);
if(!$result)
{
echo 'Your reply has not been saved, please try again later.';
}
else
{
echo 'Your reply has been saved, check out <a href="topic.php?id=' . Htmlentities($_GET['id']) . '">the topic</a>.';
}
}
Now comes the problem part. For most of the posts, I'm getting this error:
Your reply has not been saved, please try again later.
When my post content is large (length wise), this message certainly appears. But this error may appear at random too.
The query is not executing somehow how I guess. I'm using "longtext" so length shouldn't be the issue.
Can anybody find the real error?