|
Ithilion Wanderer
Joined: 02 Sep 2005 Posts: 85
|
Posted: Tue Oct 26, 2010 5:53 pm
#SQLDB and shared hosting.. |
I'm a bit confused on the wording in helpfile on either #SQLDB/%sqldb.. and it doesn't really help things when one has a shared host.. I'm trying to play with every new feature so I get an idea of how it works..
I'm using cmud pro v3 so that's not an issue with specifying db's.. I'm just getting bad variable path when I try either version of #sqldb or %sqldb, so I need a bit more of clarification :) |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Oct 26, 2010 8:12 pm |
You'll need to show us the exact #SQLDB command that you are trying to use. Shouldn't matter if you have a shared host or not. I've tested it on a MySQL server on a shared host without any trouble. Feel free to change the username/password/hostname info in your post to protect your privacy.
Also, make sure you have the proper driver DLL file for your database server in the same directory as the CMUDPRO.EXE file. |
|
|
|
Ithilion Wanderer
Joined: 02 Sep 2005 Posts: 85
|
Posted: Wed Oct 27, 2010 7:45 am |
Edit: NM, I figured #sqldb out, it's now returning Could not connect to MySQL server on www.testsite.net (0)?
and with %sqldb, it's returning bad variable type...(LoginPrompt)..
Code: |
#SQLDB Mobs_DB shareduser_table mysql-5 www.testsite.net 3305 [shared_user_db shared_pw]
Edits are specifying what I used..
shareduser refers to specifically the shared user created to admin the db, and not the root user to the site
and if i change [shared_user_db + shared_pw to root_user, root_pw] it gives me a bad required db driver not found, so I have to close cmud, delete that file, if I want to retry, which I'm assuming is SOP
|
Code: |
db=%sqldb("Mobs", "shareduser_table", "mysql-5", "www.testsite.net", "3305")
db.LoginPrompt = 1 returns bad variable, regardless of if I use db reference or $db
#call @db.open, likewise doesnt work with either db.open or $db.open
|
I've been trying to trial and error this for the last four hours, so I'm dedicated, I'm pretty sure it's just something simple I'm overlooking... |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Oct 27, 2010 5:41 pm |
Several problems confirmed. Surprised this made it past the beta testing.
1) First, the %sqldb is bugged in that it expects the "name" and "database name" arguments to be the same instead of separate. The "shareduser_table" should be the name of the *database* on the server, not a specific table. But in any case, the "Mobs" argument needs to be removed since CMUD is taking that first argument as the remote database name instead of the #SQLDB connection name. Don't worry about this because of bug #2 and I'll fix this in the next update so it works as documented.
2) The more serious problem was the "db.LoginPrompt=1" line. The LoginPrompt is a COM property of the connection and has a "type" of "boolean". But CMUD handles booleans as numeric values (0 and 1). There was a low-level COM bug in CMUD that was preventing CMUD from setting a Boolean property in some cases. Normal COM variables (created via %comcreate) worked fine, but the internal COM variables created by %sqldb and %sql (and %url) had this bug. That is what caused the "bad variable" error.
In any case, I tested the following #SQLDB line and it worked:
Code: |
#sqldb mydb databasename mysql-5 www.testsite.net 3306 username password
row = %sql(mydb,"SELECT * from tablename")
#SHOW @row.RecordCount |
and it worked for me here. Note that my database server is running on port 3306, so check the port of your database server. Don't try to use %sqldb with the LoginPrompt property. You must specify your database username and password on the #SQLDB line directly.
If the above doesn't work, then check the databasename, port, username, and password to make sure they all work. Also check with your database server to make sure that remote connections to the database server are allowed. |
|
|
|
Ithilion Wanderer
Joined: 02 Sep 2005 Posts: 85
|
Posted: Wed Oct 27, 2010 6:48 pm |
Zugg wrote: |
The "shareduser_table" should be the name of the *database* on the server |
It is, sorry. I wasnt thinking when I typed table. that's the shareduser_DB
It went to host not allowed to connect to this server, so.. that's a plus in progress... (fixed)
also, after #SQLCLOSE + re-run test alias: it says SQL server has gone away ? =( what do I do next?
I also tinkered with %sqldb a lil bit more, seeing if I could find anymore bugs..
Code: |
$db=%sqldb("MyDB", "shareduser_DB", "mysql-5", "www.testsite.net", "3306", "user", "pw")
$row=%sql(MyDB, "SELECT * FROM Mobs")
#call $db.Open
#show $Row.RecordCount
#call $db.Close
|
returns Requested DB driver not found, but it works with #SQLDB, so what gives here? Honestly? |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Oct 27, 2010 7:46 pm |
Quote: |
returns Requested DB driver not found, but it works with #SQLDB, so what gives here? Honestly? |
As I said, the %sqldb function has a messed up first argument. The first argument has to be the name of the database. So it would be:
Code: |
$db=%sqldb("shareduser_DB", "mysql-5", "www.testsite.net", "3306", "user", "pw")
$row=%sql(shareduser_DB, "SELECT * FROM Mobs") |
Quote: |
It went to host not allowed to connect to this server, so.. that's a plus in progress... |
That makes it sound like your database host is lot allowing the connection. A lot of hosting companies restrict remote connection by IP to prevent SQL attacks. You'll need to contact your database provider to find out how to get remote access. |
|
|
|
Ithilion Wanderer
Joined: 02 Sep 2005 Posts: 85
|
Posted: Wed Oct 27, 2010 8:34 pm |
I said that the host not allowing connections was fixed, you missed the (fixed) part, but yeah, I also missed re-reading your post about %sqldb, thanks for re-posting it again :( Sorry I'm such a pain today.. I 'unno why.. I really don't
but, this is the issue I was posting about (again) after #SQLCLOSE + re-run test alias: it says SQL server has gone away ? =( what do I do next? <- that part is giving me issues with #SQLDB
But! I am just going to end up using %sqldb, because it's far easier to open and close on demand, rather than deal with the issue of "cant perform operation on a closed dataset" or "SQL Server has gone away".. |
|
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|