ID:2212845
 
Code:
world/New()
..()
Connect()

var/DEF_CUR = 0
var/DB_SERVER = "localhost" // This is the location of your MySQL server (localhost is USUALLY fine)
var/DB_PORT = 3306 // This is the port your MySQL server is running on (3306 is the default)
var/DB_USER = "" //User name
var/DB_PASS = "" //Passworld
var/DB_DB = "" //Database name
var/DB_DBI = "dbi:mysql:[DB_DB]:[DB_SERVER]:[DB_PORT]" //DBI stuff
var/_db_con = 0


proc/Connect()
warning("Attempting db connection: [DB_DBI],[DB_USER],[DB_PASS],[DEF_CUR]")

. = _dm_db_connect(_db_con,DB_DBI,DB_USER,DB_PASS,DEF_CUR,null)

warning("Result = |[.]|, _db_con = |[_db_con]|")
warning("Is connected = |[IsConnected()]|")
warning("Possible error = |[ErrorMsg()]|")

proc/IsConnected()
var/success = _dm_db_is_connected(_db_con)
return success

proc/ErrorMsg() return _dm_db_error_msg(_db_con)

proc/warning(var/message)
world.log << "## WARNING: [message]"


Problem description:
I'm trying to set up an MySQL database behind my project.
However byond does not seem to want to connect.
I'm using the latest version XAMPP to host the database on a windows 8.1 machine.
The database is hosted locally and reachable by http://localhost/phpmyadmin/
As well as by MySQL Workbench. I can read/write the database with a user that has ALL PRIVILEGES created via the PHPMyAdmin on MySQL Workbench. However when I use the same user data to connect with byond it returns the following (* for sensitive info):

World opened on network port 3333.
## WARNING: Attempting db connection: dbi:mysql:feedback:localhost:*****,******,*******,0
## WARNING: Result = ||, _db_con = |0|
## WARNING: Is connected = ||
## WARNING: Possible error = ||
BYOND hub reports port 3333 can be reached by players.


If somebody can explain to me how Byond and MySQL work together and how to generate usable feedback that would be very helpfull.

EDIT: I do have libmysql.dll in the project root folder.
Do you have libmysql.dll in the same folder as your host files? You need that for it to connect.
Yes libmysql.dll is in the same folder as my dme/dmb files and source code. I don't need to do something special with the dll file right ? Like register or import them ?
Hmm, weird. Is that a library you are using, and if so, which one?
Its originally from Dantom.DB but the _dm_db_connect and alike procs are native to DM and use the libmysql.dll as far as I understand it.
See : http://www.byond.com/developer/Dantom/DB for more about Dantom.DB
In response to Rjtwins
. = _dm_db_connect(_db_con,DB_DBI,DB_USER,DB_PASS,DEF_CUR,null)


I'm wondering if the issue here is _db_con being 0. In Dantom.DB, _db_con is initialized like so:

_db_con = _dm_db_new_con()


This happens before Connect() is ever called. Based on what you posted, I don't see that variable being initialized in the same way.
Testing... watch me facepalm in a minute
Yes facepalm. that fixed it.
Thanks for the second pair of eyes!
That's why you should probably just use Dantom.DB instead of copy/pasting it into your project (that's not how libraries are meant to work)
Well I was using Dantom.DB as a part of legacy code and it was not connecting as a result of not having the right dll files. However I realized that it needed libmaraidb.dll and or libmysql.dll and made sure they where in the right place. However my project takes a bit of time to compile so I copy pasta it with hard coded server info but forgot the _db_con = _dm_db_new_con(). So it was really my test project that was not connecting while my actual would have worked :P.