actually no, it was not working at any time until i switched it to a global definition. its strange i know, but since i switched it i have had no problems at all.
Maybe you weren't closing it correctly, so it worked the first time you updated the database but any subsequent call failed because the first one was still around. That's usually a danger with opening it every time.
(besides, you don't really need to, and in fact it's arguably much more efficient to open it only once, as Whiteknight suggested)
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
WhiteKnight had it right from the start, i switched over to global definitions and an open_db_connect() at startup and now it works just fine, i can connect and query the database. wierd huh, don't know why that would be any different but learn something every day.
OK. Have you checked all the connection options? Namely, init-command.
The documentation is here:
http://dev.mysql.com/doc/refman/5.0/en/mysql-options.html
There should be a link somewhere there, or not far away, that shows how to get the current options.
Obviously PHP is connecting slightly differently from the C library...
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
No, you can't put the port into the IP address when making the connection call.
Are you *sure* that the connection is failing? Looking through the error messages for mysql_real_connect:
http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html
doesn't list that error. It does however list a number of interesting things, such as mismatching protocol versions. Are you sure you have matching/compatible protocol/library versions?
If you could get the error name as opposed to error text (e.g. get CR_CONNECTION_ERROR) that would help pinpoint the problem.
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
Changing the port from 1210 to 0 gave me this: [IMM_GEN] Stats_Player_Killed_Monster: Error: Can't connect to MySQL server on '127.0.0.1' (111)
Another thing I tried was changing MYSQL_SERVER to "127.0.0.1:1210" and that didn't work either, got this: [IMM_GEN] Stats_Player_Killed_Monster: Error: Unknown MySQL Server Host '127.0.0.1:1210' (3)
The usual questions:
- are you sure that the DB is up and running?
- are you sure that you have the right user/pass?
- are you sure that the DB has privileges set up correctly to allow your user/pass from local connections?
- is there some strange firewall configuration that would somehow be blocking local connections on that port?
- can you connect to the DB otherwise e.g. from perl or php?
i am sorry i guess i should have mentioned those things as well, i tend to assume too much. my website which is also local running php can connect and query the database just fine. the password/user is correct as well. the mud is located in the same shell as the website, so that is not an issue as well. the only thing i can assume is because i am trying to connect to it from a MUD.
One of my theories is that the database is trying to write back to the mud, the mud is not correctly handling it, and it is failing. Should that be the case I would not in a million years know how to fix it.
OK... it's important to know that it wasn't the queries.
The usual questions:
- are you sure that the DB is up and running?
- are you sure that you have the right user/pass?
- are you sure that the DB has privileges set up correctly to allow your user/pass from local connections?
- is there some strange firewall configuration that would somehow be blocking local connections on that port?
- can you connect to the DB otherwise e.g. from perl or php?
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
"I am using double quotes with 'single' quotes inside"
I'm not sure what the problem with double quotes is. If you could post your code again, with double-quotes so I can see exactly what's going on, that would be helpful.
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
Well, if I can't connect even once, how will changing it to a global connection and ran at startup change it. While I do agree, I would prefer to only connect once and point to that connection rather than multiple connection and disconnects, I first need to figure out why it won't connect.
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.