html5 sql

0 favourites
From the Asset Store
Jump on the mole rats and see how far you can go!
  • Does / will construct 2 or html 5 allow sending and receiving data from an sql database?

  • Good question. The answer is yes depending on your aims.

    To a Server

    Everything in HTML and Javascript is client side, that means, whoever is playing your game can theoretically view all the source to it. It will be obfuscated as part of the export process which will serve well in certain types of plagiarism, but for storing connections to databases, this is a big no no as anyone that can view the source and extract the database username and password could cause havock on it by executing any command they wanted. This is why there is no native support for database connections in HTML/JS.

    To Local

    However, HTML5 has introduced Web Storage, which allows you to create a database on the clients machine. More information is available at:

    http://openbit.co.uk/?p=135

    This will eventually be supported by Construct, but it will probably only be suitable for save games etc. No server interaction.

    Resolving the Server Database Issue

    Using AJAX requests, you can POST or GET data on a webpage. You will need a webserver with a database on it. Then you can send commands to the page such as "?score=3342" and the page can interpret the data and save it. So the AJAX acts as the middle man between the client and the database, which is a lot safer.

  • Thanks for the info.

    Could an Ajax extension be possibly written then for construct 2 to handle the POST / GET code stuff and simplify the process?

  • Yes! Jquery is included with exported games, and it has some excellent AJAX wrappers. These will be available in C2 soon hopefully as they open the door on what can be achieved massively.

    AJAX also will be able to manage some multiplayer online games as well (turn based and puzzle). HTML5 websockets will be able to handle real time multiplayer games.

    When the AJAX plugins are completed I'll write some tutorials on how these can be applied easily. I'll also write some sample server side code in multiple languages to make it easy for people to install.

  • AJAX also will be able to manage some multiplayer online games as well (turn based and puzzle). HTML5 websockets will be able to handle real time multiplayer games.

    This was indeed the reason why i was asking. At some point in the future i'd like to maybe have ago at making an AstroEmpires type game.

    I'm glad there are options available.

    Thanks.

  • Good question.

    Everything in HTML and Javascript is client side, that means, whoever is playing your game can theoretically view all the source to it. It will be obfuscated as part of the export process which will serve well in certain types of plagiarism, but for storing connections to databases, this is a big no no as anyone that can view the source and extract the database username and password could cause havock on it by executing any command they wanted. This is why there is no native support for database connections in HTML/JS.

    Why not just switch the .html to .php, it would still then run all the html and javascipt code but only process the php requests server side. I'm not a php/mysql expert but I'm fairly sure php code is not visible client side. The only dilemma I foresee would be not being able to include php into the js files.

  • Yes, the PHP file can be located anywhere it doesn't have to be the same page the game is located on. But the client still needs to send data to the PHP page, there is always going to be a gap between the client and the server.

  • Tom,

    You had mentioned earlier that:

    Yes! Jquery is included with exported games, and it has some excellent AJAX wrappers. These will be available in C2 soon hopefully as they open the door on what can be achieved massively.

    AJAX also will be able to manage some multiplayer online games as well (turn based and puzzle). HTML5 websockets will be able to handle real time multiplayer games.

    When the AJAX plugins are completed I'll write some tutorials on how these can be applied easily. I'll also write some sample server side code in multiple languages to make it easy for people to install.

    Do you still plan to write up a quick tutorial on how all of this is done? I plan on developing (don't laugh) an HTML5 rendition of Shadowgate that doesn't kill the user every three seconds. <img src="smileys/smiley2.gif" border="0" align="middle" /> I will need to have, of course, a login page and a way to manage which rooms, events, items etc each individual user has.

    While the method of maintaining a database on the user's computer would be simple I'm guessing it wouldn't take much for them to hack the XML or text code in the file. Hence the need for sql database connectivity. I am decent with sql and okay with php, but have almost no knowledge of AJAX.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi DropTank,

    I've added an AJAX tutorial on my to do list!

    Tom

  • <img src="smileys/smiley1.gif" border="0" align="middle" /> Sweet

  • I don't think php works on Dropbox folders, so keep that in mind if you're trying to test it there.

  • I look forward to see the Ajax tutorial. <img src="smileys/smiley14.gif" border="0" align="middle" />

  • Yes me too.

  • I'm working off a localhost using WAMP, it's free and easy to set up. When I'm ready I'm going to try it on the server and see how it goes.

  • I can't wait for the Ajax tutorial!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)