SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/09/2017, 07:58 PM   #1
Bussyman
Big Clucker
 
Join Date: Apr 2017
Posts: 161
Reputation: 0
Default random string

Hi,

Code:
stock randomString(strDest[], strLen = 10)
{
	while(strLen--)
	{
	    new nntte = random(3);

	    if( nntte == 0 )
	    {
	        nntte = random(26) + 'A';
	    }
	    else if( nntte == 1 )
	    {
	        nntte = random(26) + 'A';
	    }
	    else if( nntte == 2 )
	    {
	        nntte = arraygf[random(sizeof(arraygf))] + '0';
	    }
		strDest[strLen] = nntte;
	}
}
With this function i create random string, and i write it in mysql database i need to escape it?
Bussyman is offline   Reply With Quote
Old 04/09/2017, 08:05 PM   #2
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,964
Reputation: 2649
Default Re: random string

Oh for the love of ... Just use %e in mysql_format for whatever text you insert wherever. If it doesn't help it doesn't hurt either.

__________________
Vince is offline   Reply With Quote
Old 04/09/2017, 08:11 PM   #3
Bussyman
Big Clucker
 
Join Date: Apr 2017
Posts: 161
Reputation: 0
Default Re: random string

Yes i know need to escape, but i just ask for this specific function, do i need?
Bussyman is offline   Reply With Quote
Old 04/09/2017, 08:13 PM   #4
jlalt
Banned
 
Join Date: Oct 2014
Location: Iran
Posts: 1,287
Reputation: 366
Default Re: random string

Quote:
Originally Posted by Bussyman View Post
Yes i know need to escape, but i just ask for this specific function, do i need?
not really, as long as you don't have ; or ' characters.
and as Vince said just use %e to escape, if it won't help it won't hurt either.
jlalt is offline   Reply With Quote
Old 04/09/2017, 08:24 PM   #5
Paulice
Gangsta
 
Join Date: Jul 2017
Posts: 470
Reputation: 44
Default Re: random string

Never trust any input, these may change at any time. Escape everything.
Paulice is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Get random string HoussemGaming Scripting Help 3 27/06/2017 05:10 AM
Random messages with string Lorenzosdm Scripting Help 2 18/11/2013 08:56 PM
Random string RedFusion Scripting Help 1 21/09/2012 12:12 AM
Random text string? linuxthefish Help Archive 10 16/08/2011 08:08 PM
[ASK] How to make a string random hack4ever Help Archive 3 22/12/2010 04:56 PM


All times are GMT. The time now is 11:26 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.