DATABASE PROBLEM

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

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

DATABASE PROBLEM

Post by icesha »

* i really need help on how i can properly retreive a word existing from the database, by typing a sentence and analyzing if those words are existing.

* i also want to check spelling of the words.. the code below doesnt show any result from the database..i think i got the syntax wrong..or maybe the logic is wrong..please help me.. im just a newbie in using PHP. Thanks.

*And also if the word entered is in capital letters even though it already exists in the database it says that it doesnt. PLease tell me to upper function

Code: Select all

<?
include("ecsel_connectdb.php");
$myarray=explode(' ', $_POST['textarea']);

foreach($myarray as $a)
{
   echo " word: $a";
   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"])
	{   
            echo "$a word exist";
            echo "<br/>";                           	  
	}
 
   else
	{
             echo "sorry $a word dont exist!";
             echo "<br/>"; 
	}
}
 $string= implode(' ',$myarray);
 echo "string: $string";
 echo "<br/>"; 
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Please wrap your code in [syntax=php][/syntax] tags next time, thanks.
Post Reply