I have a little problem... And I have looked up everywhere how to convert an integer to a string. I found several ways of doing it, but with no success. So right now I have no idea of what the problem might be. I thought that I should ask you if also other people have the same problem as I do.
So what doesn't work:
$inputname = rand(1, 10000);
$inputname = "$inputname";
echo '
<h3>Translate to English</h3>
<form name="word" method="post" action="">
<table border="0">
<tr><td><label>Swedish:</label></td><td width="200"><input type="text" name="swe" maxlength="100" value="'.$swe.'" readonly /></td></tr>
<tr><td><label>English:</label></td><td width="200"><input type="text" name="'.$inputname.'" maxlength="100" /></td></tr>
<tr><td></td><td><input type="submit" name="nextword" value="Next Word" /></td></tr>
</table>
</form>
';
if (isset($_POST['nextword'])) {
$eng = $_POST[$inputname];
$swe = $_POST['swe'];
$word = $row['id'];
if($eng == $row['eng']){
mysql_query("UPDATE `words` SET `right`='yes' WHERE `id`='$word'");
}
else{
mysql_query("UPDATE `words` SET `right`='no' WHERE `id`='$word'");
}
I don't get any errors, but when I check my database it says right=no even if I typed in the correct word. If I change $inputname to a string using $inputname = "string"; it works... So why doesn't the convert work?
I have tried (string)$var, $var = "$var", mysql_real_escape_string($var) but with no success...
If you have any ideas of how to solve this please respond.
var_dump($row)andvar_dump($_POST)?