while ($row = mysql_fetch_assoc($getposts)) { $username = $row['added_by']; getInfo($username); //echo $user_info['email']; echo filterwords(' <div class="grid-item card"> <div class="card-content"> <div><!-- Name and avatar of post --> <div class="right"> <i class="material-icons grey-text hover-icon">flag</i> </div> <a href="profile.php?u=' . $user_info['username'] . '"> <img src="' . $user_info['avatar'] . '" class="circle" style="width: 50px;"> <div style="display: inline-block; position: relative; bottom: 4px; left: 11px; overflow: visible;"> <span class="title black-text">' . $user_info['first_name'] . ' ' . $user_info['last_name'] . '</span> </a> <p style="position: relative; bottom: 5px;">' . $row['date_added'] . '</p> </div> </div> <div style="padding-top: 5px;"> <p style="line-height: 24px;">' . htmlspecialchars($row['body']) . '</p> </div> </div> <div class="card-action"> <a href="#" class="teal-text">Reply</a> </div> </div> '); } ?>
$sq1 = "SELECT * FROM riddles WHERE id={$rid}"; $result = db_query($sq1) or die(db_error(LINK)); $riddle = db_fetch_assoc($result); //*** Get and filter correct answer $answer = explode(";", $riddle[answer]); //there can be more than one answer in the database, seperated by semicolons (;) foreach ($answer as $key => $answer1) { //changed "" to " " below, I believe this is the correct implementation. $answer[$key] = preg_replace("/[^[:alpha:]]/", " ", $answer1); $answer[$key] = filterwords($answer1); } //*** Get and filter players guess $guess = $_POST[guess]; // $guessdebug = $guess; // This is only for debugging, see below when the answer is wrong. $guess = preg_replace("/[^[:alpha:]]/", " ", $guess); $guess = filterwords($guess); $correct = 0; //changed to 2 on the levenshtein just for compassion's sake :-) --MightyE foreach ($answer as $answer1) { if (levenshtein($guess, $answer1) <= 2) { //Allow one letter to be off to compensate for silly spelling mistakes $correct = 1; } } if ($correct) { output("`n`6\"`@Lizards and polywogs!!`6\" he blusters, \"`@You got it!`6\"`n"); output("`6\"`@Oh very well. Here's your stupid prize.`6\"`n`n"); // It would be nice to have some more consequences $rand = e_rand(1, 10); switch ($rand) { case 1: