View Full Version : MySQL - Getting Started

31/12/2011, 08:36 AM
Right, I decided to have a go at MySQL, I looked at omse tutorials but non of them go as far as I need them to do. Basically Im up to here:

I installed wamp.

I created car saving database:

And added this in my gamemode:

#include <mysql>
forward ConnectMySQL();
public ConnectMySQL()
mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);

if(mysql_ping() == 1)
// mysql_debug(1);
printf("[MYSQL]: Connection to `%s` succesful!", SQL_DB);
printf("[MYSQL]: [ERROR]: Connection to `%s` failed!", SQL_DB);
return 1;

And now, I need some code for public SaveCar, public LoadCar, so it saves those functions in to that database or however it works and the it loads them, so please someone help me out. Thx.

((Also IDK if I used correct setting in my DB, I used float for the parameters that USE float, for everything else I used INS, is thar right or does that need changing?))

31/12/2011, 08:56 AM
I got everything sorted out, Just my server turns off when I start it.

[Sat Dec 31 09:55:39 2011] -------------------------
[Sat Dec 31 09:55:39 2011] Logging Started
[Sat Dec 31 09:55:39 2011] -------------------------
[Sat Dec 31 09:55:40 2011] Error (0): Failed to connect. Can't connect to MySQL server on 'localhost' (10061).
[Sat Dec 31 09:55:40 2011] Error (0): Function: mysql_close called when not connected to any database. Can't connect to MySQL server on 'localhost' (10061).
[Sat Dec 31 09:55:40 2011] -------------------------
[Sat Dec 31 09:55:40 2011] Logging Ended
[Sat Dec 31 09:55:40 2011] -------------------------

31/12/2011, 10:17 AM
Check that you have the correct username password and host.
Also remember to open up wamp as you have to manually start it always when you boot up your computer.