THE FOLLOWING SET NAMES UTF8 IS OUTDATED. When FIB is redone to PDO echoing this out first is no longer needed. But for now, it is necessary to mysql_query to set names to utf8 for the mysql config connection or else the characters on screen will be "???"'s*/ include_once $_SERVER['DOCUMENT_ROOT'] . "/config.php"; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); mysql_select_db($dbname); mysql_query("SET NAMES UTF8"); include $path . "/include/check_login.php"; //include_once("../include/check_login.php");//need this bc it establishes utf8 //if($user_ok == false){header('location: restricted.php?refPage=fib_r');} require_once '../config.php'; require_once '../blanks.php'; require_once '../words.php'; require_once '../stats.php'; //INCREMENT JPDRILLS_USAGE $category = preg_replace('#[^a-z0-9]#i', '', $_GET['type']); $difficulty_pre = preg_replace('#[^a-z0-9]#i', '', $_GET['diff']); $difficulty = difficulty_str_to_int($difficulty_pre); $drill_type = preg_replace('#[^a-z0-9]#i', '', $_GET['choiceQ']) != 'none' ? 'wordbox' : 'Fill-in-the-blank'; increment_usage($category, $difficulty, $drill_type); if (isset($_POST) || isset($_GET)) { if ($_POST['action'] == 'Answer') { if (isset($_SESSION['username'])) { require_once '../stats.php'; $cvset = getSkill('cvset', $userID); $query = sprintf("SELECT id FROM users WHERE UPPER(username) = UPPER('%s')", mysql_real_escape_string($_SESSION['username'])); $result = mysql_query($query); list($userID) = mysql_fetch_row($result); //assigns fetched username's 'id' to $userID to use in list fn. $player = array(name => $_SESSION['username'], confidence => getStat('conf', $userID)); } //Compare wrong and right answers $phraseID = $_POST['phraseID'];
function get_usage($category, $difficulty, $drill_type) { include "pdc.php"; $difficulty = difficulty_str_to_int($difficulty); create_usage_stat_if_not_exists($category, $difficulty, $drill_type); try { $stmt = $db->prepare('SELECT use_counter FROM jpdrills_stats WHERE category =:cat AND difficulty =:diff AND drill_type =:drill LIMIT 1 '); $stmt->bindParam(':cat', $category, PDO::PARAM_STR); $stmt->bindParam(':diff', $difficulty, PDO::PARAM_INT); $stmt->bindParam(':drill', $drill_type, PDO::PARAM_STR); $stmt->execute(); $rows = $stmt->fetchAll(PDO::FETCH_ASSOC); //FETCH_ASSOC returns array indexed by col name } catch (PDOException $ex) { echo "<p>Couldn't get usage. {$ex} </p>"; } return $rows[0]['use_counter']; //should only ever return 1 therefor can specify $rows[0][..] }