Jump to content

mysql_query account checking


Recommended Posts

Hello all again i'm because in wiki it's only 1example with query i asking in this forum how i can check if player exist in mysql db now i'm checking

    local result = mysql_query(handler,"SELECT `Name` FROM `players` WHERE `Name` = '%s'",getPlayerName(source)) 
    if(mysql_num_rows()) then 
        ouputChatBox("Vartotojas egzistuoja",source) -- Found in the db 
    else 
        outputChatBox("Vartotojas neegzsituoja",source) -- Not found 
    mysql_free_result(result) 

Problem it's with getPlayerName but i don't know how insert string in query

Link to comment
  
local result = mysql_query(handler,"SELECT * FROM players WHERE Name='"..mysql_escape_string( handler, name ).."';") 
    if result then 
        rows = mysql_num_rows(result) 
        if rows == 1 then 
            row = mysql_fetch_row(result) 
        end 
        mysql_free_result(result) 
    end 

Link to comment

Thanks for example i will try do something..

And next how about INSERT INTO ('Name','Password') VALUES ('How Insert String','And where')

Sorry but at this moment i can't get how insert strings,because i much time was working on Pawn.

BTW I Have experience on mysql just i need more example with strings

Link to comment
local result =  mysql_query(handler, "INSERT INTO player SET Name='"..mysql_escape_string(handler, Name).."', Password='"..md5(password).."';") 
        mysql_free_result(result) 

I noticed that you worked with pawn, when i saw this ^^ :

#define MySQL_HOST "localhost" 
#define MySQL_USER "root" 
#define MySQL_PASS "" 
#define MySQL_DATA "fr" 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...