<?php

include ("inc/inc_common.php");

$result=mysql_query("SELECT * FROM $spelltable WHERE intTopicId = '$topicid' AND strName = '$gfcookie[1]'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    $post = $a_row->memPost;
}


include ("inc/inc_strip_spelling.php");

$wordlist = explode(".", "$post");

$limit = count($wordlist);
$count = 0;
$wrong = 0;
while ($limit != $count)
{
    $word = $wordlist[$count];
    $orig = $word;
    $post = $word;
    include ("inc/inc_strip_spelling.php");
    $word = $post;
    if (strlen($word) < 2)
    {
        $count ++;
        continue;
    }

    $result=mysql_query("SELECT * FROM $wordtable WHERE strWord = '$word'");
    $num_rows = mysql_num_rows( $result );
    if ($num_rows == 0)
    {
        $error[$wrong] = "$word";
        $wrong ++;
    }
    $count ++;

}




if ($wrong > 0)
{
    $counter = count($error);
    $count = 0;
    while ($count != $counter)
    {
        $entry = $entry."..".$error[$count];
        $count ++;
    }
    $query = "UPDATE $spelltable SET memPost = '$entry' WHERE intTopicId = '$topicid' AND strName = '$gfcookie[1]'";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

    header("Location: topic.php?topicid=$topicid&wrong=$wrong&r=r#replyhere");
    exit;

}

header("Location: topic.php?topicid=$topicid&wrong=0&r=r#replyhere");
exit;

