After a long hiatus I'm back programming. I'm writing a hiscores script for my game, but it always returns null. Anyone got any idea how it can be fixed?
HTML/JS:
I think it is this file in which the problem rsides probably, it's for finding the highest pop;Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>The Team</title> <meta http-equiv="Page-Enter" content="blendTrans(Duration=1.0)"> <meta http-equiv="Page-Exit" content="blendTrans(Duration=1.0)"> <script> var popname = "nobody"; var city = "nowhere"; var pop = 0; var xmlHttp = createXmlHttpRequestObject(); //////////////// //////////////// //////////////// function popandciv(){ parent.location.href="index.html"; } function popandciv2(){ parent.location.href="http://web.aanet.com.au/toddmarshall/"; } //////// //////// //////// //////// function createXmlHttpRequestObject() { var xmlHttp; if(window.ActiveXObject) { //try //{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP") //} //catch(e) //{ //xmlHttp = false; //} } else { //try //{ var xmlHttp = new XMLHttpRequest(); //} //catch(e) //{ //xmlHttp = false; //} } if (!xmlHttp) window.alert("Error makin stuff work, sesifckally creatin' the Haitch Tee Tee Pee requesterization hobject sah..."); else return xmlHttp; } //////// //////// //////// ///////// FIND HIGHEST POP //////// //////// function hiscorepop() { //window.alert("processx started!") if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { //window.alert("Server ready, sending message!") nameserv = name; xmlHttp.open("GET", "hspop.php", true); xmlHttp.onreadystatechange = handleServerResponsehiscorepop; xmlHttp.send(null); } else setTimeout ('process()', 1000) } function handleServerResponsehiscorepop() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { jsonResponse = eval(xmlHttp.responseText); window.alert(jsonResponse); popname = jsonResponse; plupdate(); processpop(); } else { window.alert("H'im afarid I can not get into the server, m'lud. (xval) Aplolgies." + xmlHttp.statusText); } } } function processpop() { ////window.alert("processx started!") if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { ////window.alert("Server ready, sending message!") nameserv = name; xmlHttp.open("GET", "adbpop.php?name=" + popname, true); xmlHttp.onreadystatechange = handleServerResponsepop; xmlHttp.send(null); } else setTimeout ('process()', 1000) } function handleServerResponsepop() { if (xmlHttp.readyState == 4) { //window.alert("SERVER READY! (xval)"); if (xmlHttp.status == 200) { ////window.alert("MESSAGE RECIEVED!"); jsonResponse = eval(xmlHttp.responseText); ////window.alert(jsonResponse); newx = jsonResponse; window.alert(newx); pop = newx; window.alert(pop); popupdate(); processcityname(); //defaultx = newx; ////window.alert(defaultx); //xmymove(newx, 20); ////window.alert(newx); } else { window.alert("H'im afarid I can not get into the server, m'lud. (xval) Aplolgies." + xmlHttp.statusText); } } } function processcityname() { //window.alert("processx started!") if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { //window.alert("Server ready, sending message!") nameserv = name; xmlHttp.open("GET", "adbcityname.php?name=" + popname, true); xmlHttp.onreadystatechange = handleServerResponsecityname; xmlHttp.send(null); } else setTimeout ('process()', 1000) } function handleServerResponsecityname() { if (xmlHttp.readyState == 4) { //window.alert("SERVER READY! (xval)"); if (xmlHttp.status == 200) { //window.alert("MESSAGE RECIEVED!"); jsonResponse = eval(xmlHttp.responseText); //window.alert(jsonResponse); newx = jsonResponse; //window.alert(newx); city = newx; //window.alert(city); cityupdate(); //defaultx = newx; ////window.alert(defaultx); //xmymove(newx, 20); ////window.alert(newx); } else { window.alert("H'im afarid I can not get into the server, m'lud. (xval) Aplolgies." + xmlHttp.statusText); } } } function plupdate(){ var he = document.getElementById("plpop"); he.firstChild.nodeValue = popname + "'s mighty city of "; } function cityupdate(){ var he = document.getElementById("city"); he.firstChild.nodeValue = city; } function popupdate(){ var he = document.getElementById("popdiv"); he.firstChild.nodeValue = "With a population of " + pop; } </script> <link rel="stylesheet" type="text/css" href="./menus.css" /> </head> <body bgcolor="#000000" background="./images/backfull.jpg" text="#ffffff" onload="hiscorepop()"> <center><h1><strong>Raiders and Traders</strong></h1> </center> <center><h1><strong>Hiscores</strong></h1> <p> The largest city in Ithrala is <div id="plpop">Joe</div><div id="city">Leeds</div><div id="popdiv">0</div></p> </center> </body> </html>
I can post adbcityname and adbpop if it'd be helpful, but they're just data-grabbing scripts of quite a general form.Code:<?php $conn = mysql_connect('www.wavcott.org.uk', 'st628jg_exilian', 'exilian'); mysql_select_db("st628jg_test", $conn); $sql = "SELECT name, MAX(pop) FROM raiders"; $result = mysql_query($sql, $conn) or die(mysql_error()); while ($newArray = mysql_fetch_array($result)){ $x = $newArray['name']; } header('Content-Type: text/javascript'); echo json_encode($x); ?>
Thanks.


LinkBack URL
About LinkBacks




Reply With Quote












Bookmarks