strreplace problem
#1

I'm having some trouble with str_replace from strlib include, so i wanted to replace @ with (at) when entering email but it's not working, and idk why,


pawn Код:
mysql_real_escape_string(inputtext, escinput);
                   
                    str_replace("@", "(at)", escinput);
                   
                    mysql_real_escape_string(inputtext, escinput);
                   
                    strcpy(PI[playerid][Email], escinput);
                   
                    TextDrawSetString(RegTD[playerid][8], escinput);
Reply
#2

Use this code:

PHP код:
stock ReplaceString(const search[],const replace[], source[], size=sizeof source)
{
    new 
i=strfind(source,search),tmp=strlen(search),len=strlen(replace);
    if(
i==-1) return 0
    for( ; 
i!=-1i=strfind(source,search,false,i+len)) strdel(source,i,i+tmp),strins(source,replace,i,size);
    return 
1;

And do it like this:

PHP код:
ReplaceString("@""(at)"escinput); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)