Original Post
Below are several snippets of code related to my current web project. I'm building the user's login panel, which will display some pertinent info, as well as their rankings in ladders throughout the site. However, I've hit a pothole: the queries I'm making are resulting in empty rows...it's returning all default values for the fields but not the data I've created inside. I created the entries with phpMyAdmin, which shows them as correct and right as rain. Display page code: getStats() Function: Is this an error in my syntax? Might my database be configured incorrectly? I'm at a loss, so any help would be appreciated. [Edited by - hereticprophecy on April 14, 2007 2:40:54 AM]
<?php
include("_mysql.php");
include("functions/userpanel.php");
$userID = 1;
$stat = getStats($userID);
echo "Statistics for" . $stat['name'] . ":";
echo '<ul>';
echo '<li>' . "Level = " . $stat['level'] . '</li>';
echo '<li>' . "Experience = " . $stat['experience'] . "/" . $stat['to_level'] . '</li>';
echo '<li>' . "Tournament Wins = " . $stat['tourneyW'] . '</li>';
echo '<li>' . "Tournament Losses = " . $stat['tourneyL'] . '</li>';
echo '</ul>';
?>
function getStats($userID) {
//Connect to and select database
$dbh=mysql_connect ("localhost", "supafly2_myarcad", "base2088") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("supafly2_ultima");
//Get information for pertinent tables
$user = mysql_query("SELECT * FROM 'user' WHERE 'userID' = $userID");
$result['name'] = $user['displayName'];
//Store current level and experience to next level
require_once("level.php");
$result['level'] = getLevel($user['experience']);
$result['experience'] = truncateExperience($user['experience']);
$result['to_level'] = toLevel($result['level']);
//Store tourneys won and tourneys lost
$result['tourneyW'] = $user['tourneyWins'];
$result['tourneyL'] = $user['tourneyLosses'];
//Search all ladders for user records, store results
$result['records'] = searchLadders($userID);
//Store results of last match played TODO
//Store next scheduled match TODO
return $result;
}