im working on an hangman game but now i want to change the wordlist. Now the words are stored in a file but I want it in a mysql database.
function findword(){
if(!@$file = file('wrdslst.txt')){
echo "<div align='center'>";
echo 'There are no words in the file';
echo "</div>";
exit;
}else{
$count = count($file)-1;
if($count == 1){
return(substr($file[0],0,strlen($file[$r])-2));
}else{
function check($word){
if($word == ''){
return(false);
}else{
return($word);
}
}
$word = false;
while($word === false){
$r = rand(0,$count);
$word = substr($file[$r],0,strlen($file[$r])-2);
$word = check($word);
}
return($word);
}
}
}
I have the connection setup
include ("../inc/sql_connect.inc.php");
$query = "SELECT word FROM dba_tblwords";
$select = @mysql_query($query);
while($row = mysql_fetch_array(($select)))
{
$words[] = ($row['word']);