AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL Problem with "|" (https://forums.alliedmods.net/showthread.php?t=62129)

Nikol4u 10-19-2007 08:46

SQL Problem with "|"
 
Well, i got query and the code is like this:

Code:

            formatex(query,127, "INSERT INTO `%s` VALUES('%s','%s','%s','%s','%d:%02d','**:**','knife','%s')",sql_table,mapname,name,getcountry,authid,(climbertime[id]/60), (climbertime[id]%60),ip)
            SQL_ThreadQuery(g_SqlTuple,"addtomysql",query)

Code:

public addtomysql(failstate,Handle:query,error[],errnum,data[],size) {
    if(failstate == TQUERY_CONNECT_FAILED) {
        log_amx("Couldn't connect to SQL database.")
        client_print(0,print_chat,"[%s] Can't connect to the DB to add you in Top15 DB",ct_pluginname)
    }
    else if(failstate == TQUERY_QUERY_FAILED) {
        log_amx("Query failed.")
        client_print(0,print_chat,"[%s] Something is wrong with Top15 DB",ct_pluginname)
    }
    else if(errnum) log_amx("Error #%d: %s",errnum,error)

    else {
        client_print(0,print_chat,"[%s] Added You Successfully to Top15 DB",ct_pluginname)
    }
}

If my nick is "Nikol4u" everything is OK it adds me to the db but if my nick is "Something|Nikol4u" it doesnt add me :S how to avoid this?

Wilson [29th ID] 10-19-2007 10:15

Re: SQL Problem with "|"
 
http://support.microsoft.com/default.aspx/kb/178070

replace( the_guys_name, "|", chr(124) );

However, I don't think amxx or pawn has chr() hardcoded in, and I can't think of the correct func off the top of my head.

Can someone who knows the name of the func please reply with it?

Nikol4u 10-19-2007 14:10

Re: SQL Problem with "|"
 
A BIG THX DUDE <3

btw i used this:

Code:

replace_all(name,31,"'","\'");
THX AGAIN <3 :)


All times are GMT -4. The time now is 01:20.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.