Shoutbox

MySQL game - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: MySQL game (/showthread.php?tid=55364)

MySQL game by Dox on 01-29-2006 at 04:00 PM

I am making a game and it is supposed to send highscores from the game to a data-base but it can't connect, can somone help me?

I am using cPanel.


RE: MySQL game by Jhrono on 01-29-2006 at 04:05 PM

you've got to have the right database chosen, username password etc.. post the connection code you're using and someone will surely  help you


RE: MySQL game by Dox on 01-29-2006 at 04:13 PM

what details do I need to post?


RE: MySQL game by Stigmata on 01-29-2006 at 04:16 PM

code:
mysql_connect("localhost", "username", "password");

RE: MySQL game by Ezra on 01-29-2006 at 05:21 PM

quote:
Originally posted by Stigmata
code:
mysql_connect("localhost", "username", "password");


and also choose the right database:
code:
mysql_select_db('my_database') or die('Could not select database');


RE: MySQL game by -dt- on 01-30-2006 at 03:27 AM

or even better mysqli :D

code:
$sql = new mysqli('localhost','username','password','dbname');


then just use $sql->query() to query your database :)

http://php.net/mysqli
RE: MySQL game by Dox on 01-31-2006 at 01:24 AM

ok, for me I can establish a connection from pages on my server but is there a way to make it so every PC (running my game) can connect to the database.


RE: MySQL game by surfichris on 01-31-2006 at 02:57 AM

Using something like a Winsock control or sockets, yes.

However most MySQL servers have them set up so they can only be accessed locally or from predefined addresses.

What you need to do is write a PHP script which your game submits the scores to, and then the PHP script stores the info in the DB.