Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sending information to a Mysql table  (Read 3919 times)

0 Members and 1 Guest are viewing this topic.

Eritey

  • Newbie
  • *
  • Posts: 12
    • View Profile
Sending information to a Mysql table
« on: January 29, 2013, 08:29:29 pm »
For example, say I in my game I have a player name and I want to be able to send their player name and score to a Mysql table to form a highscore results page. How would I go about doing this? Would the game interact with the table directly or would I connect to a php script which would interact with the Mysql table?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Sending information to a Mysql table
« Reply #1 on: January 29, 2013, 08:50:59 pm »
What does it have to do with SFML?
Laurent Gomila - SFML developer

Eritey

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Sending information to a Mysql table
« Reply #2 on: January 29, 2013, 09:22:51 pm »
Well, As I've no idea how'd I go about doing it I wasn't sure if sfml was capable of doing it with its provided networking libraries. So I was just after some help with it, but if its the wrong place for this kinda of topic, feel free to close this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sending information to a Mysql table
« Reply #3 on: January 29, 2013, 10:40:15 pm »
Using TCP/UPD and communicating with a MySQL server are two different things.
I mean sure you probably could implement the whole protocol for communicating with a MySQL server on top of TCP, but there are already libraries out there that do this. So you should probably Google a bit. If you're running a webserver anyway, you could think about implementing a PHP (or similar) script, which can be easily called with SFML's network module and then let the script talk to the database. It also gives you another layer of 'security' since you won't be talking to the database directly.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

io

  • Jr. Member
  • **
  • Posts: 52
  • z/OS by day, SFML by night
    • View Profile
Re: Sending information to a Mysql table
« Reply #4 on: January 30, 2013, 08:23:05 am »
a long long time ago I can still remember how that... (ok I have a Don McLean song stuck in my head :P)

I used MySQL++ (http://tangentsoft.net/mysql++/) to wrap in SQL functionality into one of my projects; I would agree with exploiter though -- for 'safety' reasons and flexibility I'd probably communicate with a PHP script that handles the "heavy" work of the MySQL interface.

hayer

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Re: Sending information to a Mysql table
« Reply #5 on: February 08, 2013, 05:03:00 pm »
Soo you guys are saying he should create a PHP script and use that as a "proxy" between his MySQL server and C++ application?... That is just insane - to me at least.

If the application communicating with the MySQL server is a game server then you should use MySQL++ or any other C++ MySQL lib. Why? Since you control all the queries against the server and having some kind of PHP proxy just makes everything turn into syrup.

If the MySQL is meant for use client side, then your better of using something like SQLite3 or any other of the "locally stored"(or whatever you call them) database engines.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Sending information to a Mysql table
« Reply #6 on: February 08, 2013, 07:06:42 pm »
Well you've read it the wrong way. It highly depends on the use-case. If you have to store a lot of stuff and talk to the database frequently it of course makes sense to use an existing library, but one should keep in mind that by doing so, one gives the application direct access to the database, which might get exploited. To kind of prevent that one could proxy everything over a PHP script or similar, thus only the server-sided script has direct access to the database and the application has a link to the script and you can make security checks on both ends. So if you use the server just to update some online highscore the later version seems to me more secure and thus I'd use it in that situation.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/