tags:

views:

201

answers:

1

For some reason I cant post text longer than about 40~ characters..

The code

// remove space
foreach($_POST as $key => $val) $_POST[$key] = trim($val);

// check for empty fields
if (empty($_POST['comment'])) {
header("Refresh: 2; url=$_SERVER[REQUEST_URI]");
 exit('<div class="error_msg">You can\'t post a blank message.</div>');
}

// save if no problem
else {
mysql_query("INSERT INTO comments (comment, content, content_id, poster, date)
             VALUES('{$_POST['comment']}', 'thread', '$thread_id', '1', NOW())");

header("refresh: 2; url=thread.php?id=$thread_id");

// SUCCESS
}

Db:

`id` int(11) NOT NULL AUTO_INCREMENT,
`comment` text,
`content` varchar(255) NOT NULL,
`content_id` int(11) NOT NULL DEFAULT '0',
`poster` int(11) NOT NULL DEFAULT '0',
`date` datetime NOT NULL

any ideas?

and yes i gonna sanitize the $_post

thanks Tomasz

A: 

Try some basic debugging:

$sql = "INSERT INTO comments (comment, content, content_id, poster, date)
         VALUES('{$_POST['comment']}', 'thread', '$thread_id', '1', NOW())";
echo "$sql<br />";
mysql_query($sql);

Then cut-and-paste what is output into a MySQL command-line client and see if you receive any messages.

Only other thing I can think about is MySQL packet size, but that's a long shot:

mysql> show variables like '%packet%';
+--------------------+-----------+
| Variable_name      | Value     |
+--------------------+-----------+
| max_allowed_packet | 268435456 | 
+--------------------+-----------+
razzed