Page 1 of 1

[SOLVED] Connect to a mysql database online

Posted: Mon Apr 08, 2013 4:33 pm
by Nal
Hi everyone !

I am doing a project for school, the main purpose of the project is to create a game and save scores on an online database so we can access it throught our website.

We have the game, website and mysql database, the problem is that I have no clue how to connect to my database from love. I found this topic : viewtopic.php?f=4&t=11891&p=71350&hilit=mysql#p71350.

From what I understood I need sth like a mysql.dll . I found one on internet but to be honest I doubt it is something really official... anyway, I just would like to know which files I need before starting to code (any .dll or other), and inside my code how can I start the connection ?
I found something like :

Code: Select all

-- load the MySQL dll
loadlib ("mysql.dll", "luaopen_luasqlmysql") ()

-- create environment object
env = assert (luasql.mysql())

-- connect to data source
con = assert (env:connect ("databasename", "username", "password", "servername"))
Is it correct ?

Thank you for your help :) .

Re: Connect to a mysql database online

Posted: Mon Apr 08, 2013 8:20 pm
by Jackim
I've never used this, but it might be a good start:

http://www.keplerproject.org/luasql/manual.html

Re: Connect to a mysql database online

Posted: Mon Apr 08, 2013 8:52 pm
by Nal
I forgot to say I found that too, and to be honest I understand nothing about how to install it :/ .

Re: Connect to a mysql database online

Posted: Mon Apr 08, 2013 8:59 pm
by bartbes
You probably don't want to do this, because you always end up giving the "keys" to your database to the users. Typically, you create a couple of simple web pages that you can then interact with from your application.

Re: Connect to a mysql database online

Posted: Mon Apr 08, 2013 10:06 pm
by Nal
Thanks for tip ! Can you tell me which way I could interact with web pages from my game ? Is there a librairy I could use or something ?

Re: Connect to a mysql database online

Posted: Tue Apr 09, 2013 9:14 am
by Robin

Code: Select all

local http = require "socket.http"
See the documentation. It's built into LÖVE, yay!

Re: Connect to a mysql database online

Posted: Wed Apr 10, 2013 4:14 pm
by Nal
Exactly what I needed, thanks all ;) .