vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Tue Jun 18, 2013 1:45 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 9:19 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Code:
    DB_RS.Open "SELECT char FROM banned WHERE `char`='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic


Server crashes on that line... tells me to "use proper sql synax where select char from banned where char = you".


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 10:08 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Ok... its not just that line it's every line that has anything to do with the database.


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 12:00 pm 
Site Admin

Joined: Fri Jul 14, 2006 4:00 pm
Posts: 11230
Location: Washington
Nothing syntactically wrong with that, though you might want to make it a habit of always escaping your fields to avoid keyword/reserved word conflict:

Code:
SELECT `char` FROM `banned` WHERE `char`='value'


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 1:20 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
fixed:

thanks to darkfrost for pointing out 2 errors :) had an extra quote and well the other one i have no clue what did replaced char with a *.


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 3:47 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Code:
    'Check if the character exists
    DB_RS.Open "SELECT users FROM users WHERE 'name'='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic
    If DB_RS.EOF Then
        'does not exist
        Data_Send ToIndex, UserIndex, cMessage(98).Data
        DB_RS.Close
        Exit Sub
    End If

how about this one i fail at mysql queries i seem to not understand them fully... this one works but it always says the character doesn't exist even when they do...


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 7:09 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Is users a field in the table users?

anyhow it should be
DB_RS.Open "SELECT `users` FROM `users` WHERE 'name'='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic


It may also be a good idea to include the database name

DB_RS.Open "SELECT `users` FROM `databasenamehere`.`users` WHERE 'name'='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic

You can't just define it to select a table from a table, you have to choose the fields.


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 7:18 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Yeah already found that but still doesn't work...
Code:
    'Check if the character exists
    DB_RS.Open "SELECT `name` FROM `users` WHERE 'name'='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic
    If DB_RS.EOF Then
        'does not exist
        Data_Send ToIndex, UserIndex, cMessage(98).Data
        DB_RS.Close
        Exit Sub
    End If


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 9:03 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Its because you have

DB_RS.Open "SELECT `name` FROM `users` WHERE 'name'='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic

It shoudl be

DB_RS.Open "SELECT `name` FROM `users` WHERE `name`='" & Char & "'", DB_Conn, adOpenStatic, adLockOptimistic

*i've bolded the changes
Think of it something like this

things encased in ` ` are you objects, things encased in ' ' are your values.


Top
 Profile  
 
 Post subject: Re: whats wrong with this line...
PostPosted: Sat Dec 27, 2008 9:31 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
OMFG its fixed thank you seph :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 8 hours


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

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group