Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Help with KisTech MySQL Conn...

Author
Message
Mugen Wizardry
User Banned
Posted: 21st Nov 2010 21:19
Hi KisTech I am having a problem with selecting the "user" and "pass" columns from my "users" table. Could you please help?



Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 21st Nov 2010 22:58
Quote: "num_results$ = DBGetDataByColName(a, connstr$(4)) "


In the select statement you never asked it for connstr$(4), it's only returning connstr$(5) and connstr$(6).

You would need something like,

result_user$ = DBGetDataByColName(a, connstr$(5))
result_pass$ = DBGetDataByColName(a, connstr$(6))

The interesting thing about user validation is that you don't have to actually retrieve the data. Your comparison in the SELECT statement goes and finds it, and if it exists then retval will be greater than 0, which means the entry was found and the values match. You can then take the user's ID and retrieve their other data.

Mugen Wizardry
User Banned
Posted: 22nd Nov 2010 02:56
Thanks, KisTech.

But it is still crashing.

I don't know why.

I did as you said.

(I think)

Anyways, here's the code:



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
Mugen Wizardry
User Banned
Posted: 22nd Nov 2010 16:20
I still can't figure out what's going on

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Nov 2010 00:08
What's the error message?

Mugen Wizardry
User Banned
Posted: 23rd Nov 2010 01:05
there is no error.

it silent crashes

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Nov 2010 04:00
Is the code in your first post the entire program?

What plugin uses the X commands?

Mugen Wizardry
User Banned
Posted: 23rd Nov 2010 04:39 Edited at: 23rd Nov 2010 04:40
no it is just the online part.

As for the X Plugin, it is a plugin that is being developed by Axia Entertainment at http://axiaentertainment.com/

I am a beta tester for the X Plugin, so I am not at liberty to EXACTLY say what it is, alls I AM allowed to tell you is the above.

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Nov 2010 12:23
That might make it a little difficult to track down unless you can provide a version which doesn't use the external plugin MW?

I won't ask you to re-write your code either but it really helps if you use indents. Here is a quick example...

Your code:


...indented:


Mugen Wizardry
User Banned
Posted: 23rd Nov 2010 17:00
thanks baxslash

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Nov 2010 18:52
The only thing I can say without seeing more code, is that you got the result you wanted, and it's dropping through your program logic and exiting normally.

Mugen Wizardry
User Banned
Posted: 23rd Nov 2010 19:19
No DBRunSQL is the line it's crashing on.

I CANNOT remove the X Plugin code as it is needed for the input box controls and login window etc.

BUT I DID remake ALL the code of the ENTIRE online code in my game

Code:



Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Nov 2010 19:44 Edited at: 23rd Nov 2010 19:46
Then it must be giving some kind of error, otherwise you would never know that it's that line it's crashing / closing on.

[edit]
However, the way the code above is written, you aren't connecting to the database before you try and run a query.

Mugen Wizardry
User Banned
Posted: 23rd Nov 2010 20:04
yea i do.

It's in the While loop.

I just have it so you click the login button before it connects

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD! http://www.imageposeidon.com/
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 23rd Nov 2010 21:49
I've looked through it a couple of times now and am having trouble following the logic because of the lack of indentation. (which is probably why others haven't chimed in much.)

You yourself are going to find it MUCH easier to follow the logic of your own code if you indent, and once you do that you will probably find the problem.

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 23rd Nov 2010 22:52
I also had a look through the code and as KISTech said, it's very hard to follow. I tried indenting the first 150 lines or so and it got very convoluted! There are huge areas of that code which are never executed and look irrelevant to your crash problem. (Specifically code conditions on `onlinemode` and `dbtype`)

Nobody (with the exception of a few masochists ) is going to wade through 500+ lines of unstructured code because there is an hours work there tidying things up before you can even begin to debug your actual problem.

Really try and strip that code to it's barest form. No GUI, no user input, hardcode variables. Also, stick with just one instance of `onlinemode` and `dbtype` until you have it working, then add back in the variations. If you're sure that it's crashing on the DBRunSQL line then save the generated query string before the command executes and post it here.
Mugen Wizardry
User Banned
Posted: 24th Nov 2010 22:02
Working on it

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 28th Nov 2010 00:40
Here's the new code.



CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 28th Nov 2010 01:44
1. You've defined variables as Global, then defined them again as locals. When you define a numeric variable, it's default value is 0.

2. dbtype, conn, onlinemode, are all set to 0. Your program logic hits two of the IF statements, neither of which get executed, then it reaches your functions and just exits.

3. Indent only the logic of loops and branch statements. It took about 20 minutes to pick through it, but this is much easier to read.



Hope that helps at least a little.

Mugen Wizardry
User Banned
Posted: 28th Nov 2010 02:40 Edited at: 28th Nov 2010 03:35
Ok it's STARTING to work.

Now I'm having another problem that's making it still crash.

The problem is:

conn = DBRunSQL("SELECT "+connstr$(5)+","+connstr$(6)+" FROM "+connstr$(4)+";")

Which returns:

SELECT user,pwd FROM users;

Here's the code:



Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 28th Nov 2010 19:10
Leave off the semicolon.

Mugen Wizardry
User Banned
Posted: 28th Nov 2010 22:08
That still didnt work

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 29th Nov 2010 19:09
I wish I could help more, but our holiday weekend is over and I have to get back to work.

I can say, your program is much more complex than it really needs to be. Try not to use so many variables, and just go ahead and type out "SELECT user, pass FROM users WHERE user = '"+user$+"' AND pass = '"+pass$+"'"

Break down what you have, and simplify. It will make your life much easier.

Mugen Wizardry
User Banned
Posted: 29th Nov 2010 19:26
conn = DBRunSQL("SELECT user, pass FROM users")

still doesn't work

is there some way to get the error its having in an alert box so i can track it down and be done with this problem?

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 29th Nov 2010 20:56
If there's anything in the MySQL database, this should give you something. Like I said, "Break it down and simplify." Test new pieces by itself and learn how it works. Then it will be easier to integrate into your application.



If there are errors in the syntax of your connection string, or the SQL statement, or if your SQL server isn't set up properly, the error messages should help to track it down.

Mugen Wizardry
User Banned
Posted: 29th Nov 2010 21:02
Nvm. I FINALLY fixed it.

Thanks KisTech! ^^

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 1st Dec 2010 23:07 Edited at: 1st Dec 2010 23:08
Ok. Getting a crash with the following lines:

userdata = DBRunSQL("SELECT "+connstr$(5)+","+connstr$(6)+" FROM "+connstr$(4))


For a=0 to conn-1

result_user$ = DBGetDataByColName(a, connstr$(5))
result_pass$ = DBGetDataByColName(a, connstr$(6))

If ulogin$=result_user$ and upass$<>result_pass$

Here's the code:



I KNOW the problem is with the MYSQL line.

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 3rd Dec 2010 02:11
Anyone? :/

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 3rd Dec 2010 04:58
` Run our test SQL Statement
userdata = DBRunSQL("SELECT "+connstr$(5)+","+connstr$(6)+" FROM "+connstr$(4))

For a=0 to conn-1

Shouldn't it be "for a = 0 to userdata-1"

Mugen Wizardry
User Banned
Posted: 3rd Dec 2010 05:34 Edited at: 3rd Dec 2010 05:36
Thanks, Kistech. There is ONE more problem left.

For some reason, it's crashing at this line:

DBR = DBConnect("DRIVER="+driver$+";SERVER="+connstr$(0)+";DATABASE="+connstr$(1)+";UID="+connstr$(2)+";PASSWORD="+connstr$(3)+";OPTION=3;Encrypt="+connstr$(7))

in this function:



Here's the code stripped down to what is needed to make the net code function:



I'm down to 1 error. It's ALL downhill from here!

Thanks!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
Mugen Wizardry
User Banned
Posted: 3rd Dec 2010 15:53 Edited at: 3rd Dec 2010 17:43
EDIT: This problem has been solved!

CHECK OUT SOME MUSIC FROM MY NEW TECHNO CD! TECHNOKINESIS
http://www.youtube.com/watch?v=4a8KedfgVv0
ALSO, CHECK OUT MY NEW TECHNO CD AT Amazon.com!
KISTech
18
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 3rd Dec 2010 17:58
Whenever a problem is solved, share the solution so that anyone searching later can learn from it as well.

Login to post a reply

Server time is: 2026-07-21 18:58:31
Your offset time is: 2026-07-21 18:58:31