having problems with PSELL.keeps outputting a warning..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
icesha
Forum Newbie
Posts: 11
Joined: Tue May 01, 2007 3:15 am

having problems with PSELL.keeps outputting a warning..

Post by icesha »

hello. i am having problems with the pspell spell check my syntx is correct but warnings keep appearing. but it only appears after the second sentence.
i am studying PHP on my on. and i would really be grateful if someone will reply. thank you veyr much.


example: input from textfield: this is a test. i am checking.
here is my code:

Code: Select all

<?php
include("ecsel_connectdb.php");

$var= $_POST['textfield'];
$mypar=explode('.',$var);
//sentence

foreach($mypar as $b)
{
$b=trim($b,"\t\r\n .");
echo "$b - This is a sentence";
echo "<br/>";
echo "<br/>";
}//end first for

$myarray=explode(' ',$var);
foreach($myarray as $a)
	{
 
	 $a=trim($a, "\t\r\n ."); 	
	 
	 	 	   
	 $pspell_link = pspell_new("en");
   		 if (pspell_check($pspell_link, $a))
   			{	
				echo "$a - This is a valid spelling";
				echo "<br/>";  
				echo "<br/>"; 	
     		} //end if
  		 else 
			{		
				echo "$a - Sorry, wrong spelling";
				echo "<br/>"; 
				echo "<br/>"; 
  
                $pspell_link = pspell_new("en");
                  if (!pspell_check($pspell_link, $a)) 
					   {
       				 		$suggestions = pspell_suggest($pspell_link,$a);
    						foreach ($suggestions as $suggestion) 
							{
       							echo "Possible spelling: $suggestion<br />";
								//echo "<br/>";  
							}//end inner for
					  }//end inner if
			}//end  else
							
	    //query word
		echo " word: $a";
     	echo "<br/>";
     	echo "<br/>";
		
   		$sql="SELECT WORD FROM WORDS where WORD= '$a'";
   		$sql_result=mysql_query($sql,$connection) or die ("Couldnt execute query at WORDS");
	    $row= mysql_fetch_array($sql_result);
	   
   	    if($a==$row["WORD"])
		{   
	    
          	 $sql1= "SELECT MARK FROM WORDS where word ='$a'";
           	 $sql_result1= mysql_query($sql1,$connection) or die ("Couldnt execute query at words");
	   	     $row1=mysql_fetch_array($sql_result1);
	    
           	 $dis = $row1["MARK"];
			 echo "$a is $dis";
	   	     echo "<br/>";
	  	     echo "<br/>";            	
		}//end if
    	else
		{
          	   echo "$a - noun";
           	   echo "<br/>"; 
	    	   echo "<br/>"; 
		}//end else
	
	}//end 2nd for

$string= implode(' ',$myarray);
echo "string: $string";
echo "<br/>"; 
echo "<form method=\"get\"action=\"Essay.php\"><input type =\"submit\"value=\"Back\"><form/>";


?>
the output is like this

Code: Select all

word: is

is is linking verb

a - This is a valid spelling

word: a

a - noun

test - This is a valid spelling

word: test

test - noun


Warning: pspell_new() [function.pspell-new]: PSPELL couldn't open the dictionary. reason: No word lists can be found for the language "en". in C:\Program Files\php\xampp\htdocs\xampp\ECSEL\icesha.php on line 62

Warning: pspell_check() [function.pspell-check]: 0 is not a PSPELL result index in C:\Program Files\php\xampp\htdocs\xampp\ECSEL\icesha.php on line 63
i - Sorry, wrong spelling

word: i

i is pronoun should always be followed by a linking verb 

am - This is a valid spelling

word: am

am is linking verb

checking - This is a valid spelling

word: checking

checking - noun

string: this is a test. i am checking.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Re: having problems with PSELL.keeps outputting a warning..

Post by volka »

please post the warning messages.
Post Reply