Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, exile, Ayumi), 836 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 4
Page 4 of 24 1 2 3 4 5 6 23 24
Re: MySQL dll [Re: KyiasShadow] #41647
04/30/05 08:29
04/30/05 08:29
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
First define the function:
Code:
 
//--------------------------------------------------------------------
// DLL-declarations
//--------------------------------------------------------------------
dllfunction mySQL_Connectdb(w,x,y,z); // declaration of a DLL function
dllfunction mySQL_Closedb();
dllfunction mySQL_ExecQuery(string);
dllfunction mySQL_GetVal(x,y);
dllfunction mySQL_GetStr(string,x,y);
dllfunction mySQL_RowNumber();
dllfunction mySQL_IsConnected();



Then you can connect to the database with this little piece of code:
Code:
 mySQL_Connectdb("database","localhost","username","password") 


Change the database, localhost, username and password to your own.

Then you can execute a normal mysql query with mySQL_ExecQuery('query');
(there are tons of tutorials explaining this on the internet).

Now it's time to look at the information using either:
Code:
 
mySQL_GetVal(x, y); // gets the var value of the position x,y in the returned data
mySQL_GetStr(string, x, y); // assigns the value of x,y to the string string



Hope this helped a bit.

Re: MySQL dll [Re: Wiz] #41648
04/30/05 09:51
04/30/05 09:51
Joined: Mar 2004
Posts: 217
UK (Peterborough)
KyiasShadow Offline
Member
KyiasShadow  Offline
Member

Joined: Mar 2004
Posts: 217
UK (Peterborough)
Yep this has helped allot.

Has anyone done any work on a user login and register part in there game? just thinking thru ho w the hell im gona go thru this in C, its not the same as doing it in php :P

Anyone got any tips?


A6 Commercial V6.3 1024MB DDR RAM P4 2.8GHz 256MB GeForce FX 5600 160GB HDD
Re: MySQL dll [Re: KyiasShadow] #41649
04/30/05 11:06
04/30/05 11:06
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
I am working on a system for that right as I type, but I just started out so it may take a while before I have something to show.

Re: MySQL dll [Re: Wiz] #41650
04/30/05 13:23
04/30/05 13:23
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
Ok, now I've made a simple login system using inkey and a short sql query. It works quite well actually. First it takes input from the user stating both username and password, then it puts that information into a string containing a query for the a record with this username and password in the users table. If there is no such record it terminates, if it exists it continues to load information about the user from the db.

Re: MySQL dll [Re: Wiz] #41651
05/01/05 01:10
05/01/05 01:10
Joined: Mar 2004
Posts: 217
UK (Peterborough)
KyiasShadow Offline
Member
KyiasShadow  Offline
Member

Joined: Mar 2004
Posts: 217
UK (Peterborough)
Thisis the bt that lost me, using the SQL in with C. how using th strings with the SQL? you have a small example? i learn faster that way lol.

done php about 2 years ago and it was much different using sql.

Im using Inkey anyway.

thanks


A6 Commercial V6.3 1024MB DDR RAM P4 2.8GHz 256MB GeForce FX 5600 160GB HDD
Re: MySQL dll [Re: KyiasShadow] #41652
05/01/05 08:00
05/01/05 08:00
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
You can make the normal type of sql query:
select * from users WHERE username='USERNAME' AND password='PASSWORD';

You can create this string in c-script using the str_cat function:
Code:
 
string query; // holds the mysql query
string username; // holds the username
string password; // holds the password

//Take input here//

str_cat(query, "select * from users WHERE username='");
str_cat(query, username);
str_cat(query, "' AND password='");
str_cat(query, password);
str_cat(query, "';");



The str_cat function basically adds the second string given to the function at the end of the first string. For more information on this function, look it up in the manual.

Re: MySQL dll [Re: Wiz] #41653
05/01/05 08:54
05/01/05 08:54
Joined: Mar 2004
Posts: 217
UK (Peterborough)
KyiasShadow Offline
Member
KyiasShadow  Offline
Member

Joined: Mar 2004
Posts: 217
UK (Peterborough)
Ok. yep i understand this.

Now what happens if the user gets their password of username wrong? how do i check to see if its in the database and if its right or wrong? could i put this SQL into a IF statment?


A6 Commercial V6.3 1024MB DDR RAM P4 2.8GHz 256MB GeForce FX 5600 160GB HDD
Re: MySQL dll [Re: KyiasShadow] #41654
05/01/05 09:14
05/01/05 09:14
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
You could check how many rows are returned after the query by using the command mySQL_RowNumber(). If it returns 1 then it should be ok, but if it returns 0 something is wrong because then it hasn't found anything.

Re: MySQL dll [Re: Wiz] #41655
05/01/05 16:44
05/01/05 16:44
Joined: Mar 2004
Posts: 217
UK (Peterborough)
KyiasShadow Offline
Member
KyiasShadow  Offline
Member

Joined: Mar 2004
Posts: 217
UK (Peterborough)
Yes yes. but how? i really stuck here. i have inkey on the username? do i need 2 inkeys? no? And do i use if staments to work this out if theres a user in teh databse or not? is what ima sking :P

Do you know of any examples? been screwing my brain over this all night


A6 Commercial V6.3 1024MB DDR RAM P4 2.8GHz 256MB GeForce FX 5600 160GB HDD
Re: MySQL dll [Re: KyiasShadow] #41656
05/01/05 17:17
05/01/05 17:17
Joined: Dec 2004
Posts: 306
Planet Earth
Wiz Offline
Senior Member
Wiz  Offline
Senior Member

Joined: Dec 2004
Posts: 306
Planet Earth
Call this from main:
Code:
 

string query;
string username;
string password;

function userlogin(){

if(!mySQL_IsConnected()&&!mySQL_Connectdb("dbname","localhost","dbuser","dbpass")){
beep;exit;
}


inkey(username);
inkey(password);

str_cat(query, "select * from users WHERE username='");
str_cat(query, username);
str_cat(query, "' AND password='");
str_cat(query, password);
str_cat(query, "';");

if(mySQL_ExecQuery(query)&&mySQL_RowNumber()==1){
loggedinok=true;
}else{
exit;//if no entry, exit
}


//now you can gather info from the db

mySQL_Closedb();
}


This is a quick code I trew togheter, but you will see the main principles. Of course you may alter the code that exits if there is no such account, maybe show an error and let the user try again.

Page 4 of 24 1 2 3 4 5 6 23 24

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1