Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Data entry

monsenmonsen Member Posts: 2
Hello guys!
I'm making a multi-lingual dictionary. I have a problem with the data entry. I want to check if the word already exists in dictionaries database. if yes, notify me, else, insert it. Also the English table should contain this word. for example, the word feu = fire in french, if I added it, my script should check if 'fire' exists in english dictionary, if not add it.
I get funny results. I know it's due to a mistake in my code. I need your help.

[code]<?php<br />/*
1- check if data exists in $Dictionary table, if yes, notify me, else, insert and show confirmation.
2- check if $translation exists in English dictionary, if yes, notify me, else, insert it as a new english word.
*/

//inputs
$dictionary = $_POST['language'];
$word = $_POST['word'];
$translation = $_POST['translation'];
$wordtype = $_POST['wordtype'];
$extra = $_POST['extra'];

$con= mysql_connect("localhost","root","")or die('couldn't connect to mysql'. mysql_error());
mysql_select_db("dictionaries",$con);

$check = mysql_query("SELECT COUNT(*) FROM $dictionary WHERE Word = '$word'",$con);
$checkEnglish = mysql_query("SELECT COUNT(Translation) FROM English WHERE Word = '$translation'",$con);
$updateEnglish = mysql_query("INSERT INTO English(Word,Translation,Wordtype)Values('$translation','$translation','$wordtype')",$con);
$query =mysql_query("INSERT INTO ".$dictionary." (Word,Translation,Wordtype,extra) values('$word','$translation','$wordtype','$extra')",$con);

print"



A:active
{
font-weight:bold;color:orange;
text-decoration:none;
}
A:hover
{
font-weight:bold;
color:crimson;
text-decoration:underline;
}
UL
{
font-weight:bold;color:royalblue;
} echo ".$dictionary." database entry

";

if(mysql_num_rows($check)>0)
{
print "
".$word." already exists in ".$dictionary." database";
}
else
{
mysql_query($query,$con)or die('couldnt execute query:'. mysql_error());
print " image 

$dictionary Database entry


Word $word Translation $translation Word Type $wordtype Dictionary $dictionary
";
}
if(mysql_num_rows($checkEnglish)!=0)
{
print "
$translation is already found in the English dictionary";
}
else
{
mysql_query($updateEnglish,$con);
echo "$translation was not found in English dictionary, I just added it there.
";
}



mysql_close($con);
?>


Ok
[/code]
thanks

Sign In or Register to comment.