like i said before the insert function
i would recommend using single quotes ' ' instead of double quotes and backslashes in your sql commands, much easier to read and easier to program 😉
<?php
session_start();
include("connectdb.inc.php");
include("loginscript.php");
$year= date ("Y");
$month= date ("m");
$day= date ("d");
// ADDSLASHES START
$topic = addslashes($topic);
$text = addslashes($text);
// ADDSLASHES END
mysql_query("insert into forum (position, topic, views, replies, poster, date, cat, text) values(\"1\",\"$topic\",\"0\",\"0\",\"$sessionusername\",\"$day/$month/$year\",\"$cat\",\"$text\") ");
mysql_query("update forum set position=\"1\" where id=\"$id\" ");
$getall=mysql_query("select * from forum");
$count=mysql_num_rows($getall);
$counter=0;
while ($counter<=$count) {
$counter=$counter+1;
while ($row=mysql_fetch_array($getall) )
{
$idother=$row[id];
$pos=$row[position];
$pos=$pos+1;
mysql_query("update forum set position=\"$pos\" where id=\"$idother\" ");
} }
?>
then when return it from the database, eg in a while loop
while ($row = mysql_fetch_array($query)) {
$text = stripslashes($row[text]); // strip slashes
$text = nl2br($text); // add break lines
$topic = stripslashes($row[topic]);
echo $topic;
echo "<br><br>";
echo $text;
}