help with online high scores
I'm working on a marathon runner game ( http://www.locopuyo.com/MarathonRunnerBeta1.zip ) just for the fun of it. What I am wondering is what the best way to make a high scores list would be.
I have mySQL on my server, I don't know if that is the best way to do it though.
I don't know at all how to connect files on the internet with java.
I was thinking it might be easier if I just had a plain html web site that I could edit in my java program using ftp, but I don't know how to do that and dont' even know if it is possible.
Any help would be much appretiated.
[604 byte] By [
locopuyoa] at [2007-10-2 4:20:42]

SQL is my preference for storing almost anything.
okay, so do you know of any good tutorials or anything to help me get started?
since you have MySQL on your server, I'm going to go ahead and assume you have PHP installed also. If so, you can do the highscore work in PHP and just have the game query that script. Basically (if you know anything about PHP and web queries in general) you just query the URL of the PHP script with a few GETVARS. In the simplest (and most easily hacked) way is something like:
http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000
highscore.php (your script) would then use MySQL to store the data of the GETVARS ($action,$name, and $score).
All you need in Java to query this script is the URL class.
URL url = new URL("http://yourserver.com/game/highscore.php?action=submit&name=bob&score=5000");
url.openConnection(); // this is where it is queried
highscore.php is where you need to do your database work. If you don't know anything about PHP or if this sounds too easily hacked, you might look into connecting to MySQL via JDBC (see [url=http://java.sun.com/docs/books/tutorial/jdbc/index.html]tutorial[/url])
If I find the time I can make a simple template for you to build off of
Thanks for the help.
Well I don't know anything about MySQL and JDBC and after looking at the tutorial it looks like I have a lot to learn if I want to use that.
I'll try out the php idea you have. I haven't used php much, just if statements checking resolution and browser identification.
That would be really nice if you helped me out with a simple template.
I worked on getting the game ready to work with the high scores. Now after the race is finished a window pops up saying the score and the race. Here I'll put in a textbox for the user to type their name. Then upload the score. http://www.locopuyo.com/MarathonRunnerBeta2.zip
I wrote a PHP script for you to use. After adjsuting the settings of the script it should be fairly easy to use it with your Java program.You can find the template on my site here: http://woogley.net/misc/Highscore/
Thanks, that helps a lot! I'll let you know when I get it working.
Okay, I got most of the high scores working using the tutorial you made. In the game I can read the high scores and print them to the screen. I manually submitted a few scores with my web browser, but I can't get it to submit any in my java game.
I have a
public class submitpressed implements ActionListener{
public void actionPerformed(ActionEvent event){
name = typeArea.getText();
try{
URL url = new URL("http://locopuyo.com/highscore.php?action=submit&admin_user=xxxxxx&admin_pass=0000000&name=george&score=199900&access_code=0000000");
System.out.println(name +timeTaken);
}
catch(Exception e){
e.printStackTrace();
}
}
}
I know it gets tried because the printline prints the name and time taken out, but the scores scores list never changes. Anybody know what is wrong? Before I had it where it would change the name and score in the URL and it didn't work either but I changed it for testing purposes.
I also changed the password and username for security reasons. When I paste the exact URL into a web browser it works.
Okay nevermind, I just got it to work.I just had to putInputStream in = url.openStream();after I made the url.