Hi there, I hope someone can help as I've been tearing my hair out with this one for hours! I have the following page in my Drupal site:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="http://www.warhawkinfo.com/scripts/jquery.jeditable.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(function()
{
$(".click").editable("http://www.warhawkinfo.com/save-tracker.php",
{
indicator : "<img src='http://www.warhawkinfo.com/images/ajax-indicator.gif'>",
tooltip : "Click to edit this item...",
style : "inherit"
}
);
}
);
</script>
<?
if (user_is_logged_in()) {
#CALL GLOBAL VARIABLE FOR USER DATA
global $user;
#GET PSN
$me = user_load(array('uid' => $user->uid));
$psn = $me->profile_psn;
#CONNECT TO TRACKER DATABASE
$sql_un = "username";
$sql_pw = "password";
$sql_db = "the-immortality_com_tracker-codwaw";
mysql_connect("127.0.0.1", $sql_un, $sql_pw);
mysql_select_db($sql_db) or die("Unable to connect to CoD-WaW Tracker database.");
#IF USER IS NEW TO TRACKER (FIRST VISIT), ADD DEFAULT DATA
if(!mysql_num_rows(mysql_query("SELECT psn FROM missions WHERE uid = '$user->uid'")) > 0)
{
mysql_query("INSERT INTO multiplayer (uid,psn,prestige,rank,time_played_days,time_played_hours,world_ranking,kills,deaths,wins,losses,kill_streak,death_streak,win_streak,fav_weapon,lfav_weapon,fav_pistol,lfav_pistol,dog_kills,artillery_kills) VALUES ('$user->uid','$psn','0','1','0','0','Unknown','0','0','0','0','0','0','0','Unknown','Unknown','Unknown','Unknown','0','0')");
mysql_query("INSERT INTO missions (uid,psn,semper_fi,little_resistance,hard_landing,vendetta,their_land_their_blood,burn_em_out,relentless,blood_and_iron,ring_of_steel,eviction,blackcats,blowtorch_and_corkscrew,breaking_point,heart_of_the_reich,downfall) VALUES ('$user->uid','$psn','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No')");
mysql_query("INSERT INTO trophies (uid,psn,get_your_hands_dirty,bloody_peleliu,the_sword_is_broken,architect,the_hammer_strikes,scorched_earth,fearless,hell_on_wheels,no_return,when_it_rains_it_pours,one_bad_gato,blowtorch_and_corkscrew,the_sun_sets,for_the_motherland,bearing_the_burden,saved_private_ryan,weapon_of_mass_destruction,lights_out,rough_economy,guardian_angel,close_shave,snake_in_the_grass,no_safe_place,purple_heart,ruthless,mortardom,shot_in_the_dark,blue_ribbon,get_your_left_foot_wet,get_your_right_foot_wet,carlsons_raiders,stormed_peleliu,the_last_stand,stabbed_in_the_heart,the_professional,gunslinger,grave_robber,throw_a_six_and_a_half,firestarter,kamikaze,iron_fist,sum_of_all_zeroes,hardened_war_hero,war_hero,platinum) VALUES ('$user->uid','$psn','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No','No')");
}
?>
Welcome to your personal CoD:WaW Tracker <? echo $psn; ?>. This tool allows you to record and maintain various statistics of your CoD:WaW gaming such as what missions you have completed and what trophies you have attained. Your statistics can be edited at any time and all the data you provide will be used in your TB$ profile.
To better use this facility, we highly recommend you register to <a href="http://www.callofduty.com">www.callofduty.com</a> and link your stats so that your stats are as accurate as possible.
<br>
<br>
<hr>
<br>
<div align="center" style="font-family: Arial Black; font-size: 24px; color: black">
<b>Multiplayer Statistics</b>
</div>
<?
#GET USERS MULTPLAYER STATISTICS
$result = mysql_query("SELECT * FROM multiplayer WHERE uid = '$user->uid'");
$mpstat = mysql_fetch_row($result);
?>
<br>
<table>
<tr>
<th>Prestige</th>
<? echo ($mpstat[2] > 0) ? '<td><img title="Prestige ' . $mpstat[2] . '" src="/images/prestige_icons/prestige' . $mpstat[2] . '.png"> (Prestige ' . $mpstat[2] . ')</td>' : '<td>Not Prestiged</td>'; ?>
</tr><tr>
<th>Rank</th>
<td><? echo $mpstat[3]; ?></td>
</tr><tr>
<th>Time played</th>
<td><? echo $mpstat[4]; ?> days, <? echo $mpstat[5]; ?> hours</td>
</tr><tr>
<th>World ranking (score)</th>
<td><div id="world_ranking" class="click" style="display: inline"><? echo $mpstat[6]; ?></div></></td>
</tr><tr>
<th>Kills</th>
<td><? echo $mpstat[7]; ?></td>
</tr><tr>
<th>Kills from Dogs</th>
<td><? echo $mpstat[18]; ?></td>
</tr><tr>
<th>Kills from Artillery</th>
<td><? echo $mpstat[19]; ?></td>
</tr><tr>
<th>Deaths</th>
<td><? echo $mpstat[8]; ?></td>
</tr><tr>
<th>Kill to Death Ratio</th>
<td><? echo round($mpstat[7] / $mpstat[8], 2); ?></td>
</tr><tr>
<th>Kill Streak</th>
<td><? echo $mpstat[11]; ?></td>
</tr><tr>
<th>Death Streak</th>
<td><? echo $mpstat[12]; ?></td>
</tr><tr>
<th>Wins</th>
<td><? echo $mpstat[9]; ?></td>
</tr><tr>
<th>Losses</th>
<td><? echo $mpstat[10]; ?></td>
</tr><tr>
<th>Win to Loss Ratio</th>
<td><? echo round($mpstat[9] / $mpstat[10], 2); ?></td>
</tr><tr>
<th>Win Streak</th>
<td><? echo $mpstat[13]; ?></td>
</tr><tr>
<th>Favourite Weapon</th>
<td><? echo $mpstat[14]; ?></td>
</tr><tr>
<th>Least favourite Weapon</th>
<td><? echo $mpstat[15]; ?></td>
</tr><tr>
<th>Favourite Pistol</th>
<td><? echo $mpstat[16]; ?></td>
</tr><tr>
<th>Least favourite Pistol</th>
<td><? echo $mpstat[17]; ?></td>
</tr>
</table>
<? } else { ?>
<p>You are not logged in. You need to login or register to access this page.</p>
<br>
<br>
<? } ?>
And the following code in my "save-tracker.php" file:
<?
global $user;
$sql_un = "username";
$sql_pw = "password";
$sql_db = "the-immortality_com_tracker-codwaw";
mysql_connect("127.0.0.1", $sql_un, $sql_pw);
mysql_select_db($sql_db) or die("Unable to connect to CoD-WaW Tracker database.");
$world_ranking = $_POST["value"] ;
mysql_query("UPDATE multiplayer SET world_ranking= '$world_ranking' WHERE uid = '$user->uid'") or die(mysql_error());
echo $world_ranking;
?>
I'm currently using the World Ranking statistic to begin to get it working. Everything seems to go fine on the page when I edit the statistic, it changes and reflects the new value. If I reload the page however, my mysql database has not been updated from the POST'd value. Any idea's why?
~Liam