Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to get into online games programming. I thought that as a start i'd be a good idea to implement an online database that would store the progress and score for a game i have made, i'll probably want to implement an account system too.

My issue is, i can't see to be able to ask google the right question. I don't know where to start. I've touched some on SQL and PHP, HTML and XSL, but, to me they're just languages, i can't see the big picture, how do these things connect to form a working service? I'm not looking for a solution, i just don't know what should i learn.

I'm not looking for knowledge on sockets, i'm familiar with network programming, i just don't understand the "modern" process of handling databases. I'd be very happy if somebody could lay out the structure of a database, how you put it out on the web, how you access the information and change it (not in a direct solution, just "this is done by programming a filter in SQL"), what languages are used for it, etc.

share|improve this question
This is not where I would start with making games. Start with the rendering and gameplay first. – stephelton Feb 15 '12 at 6:15
"for a game i have made", i don't think i was being vague here – dreta Feb 15 '12 at 7:31
@stephelton: what if he wants to make a webgame? ^^ – o0'. Feb 15 '12 at 8:21
@Lohoris he still has to draw things and there is still some gameplay mechanicisms involved... – stephelton Feb 15 '12 at 15:04
up vote 4 down vote accepted

The database is the backend, your game is the client. Since you can't (well, technically you can but you really shouldn't) connect to the DB directly, you'll have to write some kind of middleware for that.

The middleware usually runs as a web-service or deamon on a server and exposes an interface for you to access/store game data. This stuff can be implemented in a lot of different languages.. basically any language that you can run on a server and access a database with.

For things like highscores, achievements etc. you can write a simple PHP (or Ruby, Java,..) script that you can access via HTTP. A common architecture for web APIs like this is REST. If you would implement a highscore system as RESTful service, you might have an URL like this:

Sending a GET request to that URL would fetch the scores from the DB and return them (you could send them as XML, JSON or similar).

To add a new score-entry, you maybe have an URL like:

And you would send a new Highscore to that address using a HTTP POST request. Then you read out the POST data and insert it into the database.

Of course you don't have to conform to any architecture (such as REST), but I'd say it's good practice.

Here are some things you should be aware of when you do something like this for the first time:

  • Don't trust the client. If your game can send a highscore, anybody else can do so also... this question touches on that topic.

  • Always validate and sanitize incoming data (remember, don't trust the client). Being sloppy with these things will make your service susceptible to SQL injection attacks.

share|improve this answer
thank you, at first this didn't sound like the answer i was looking for, but after googling for the past 2 days it all became clear. i create a database, put it on a server, then i create a script as an interface to run on the server and use URLs to query the server and recieve or send the information i want, it's exactly like you've said, i'm just a dummy, thank you so much. – dreta Feb 16 '12 at 2:18
@dreta You got it right. Glad it helped. – bummzack Feb 16 '12 at 8:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.