PDA

View Full Version : Letters in codes?


SilverDragonTears
12-29-2011, 04:22 PM
How can I add letters into the codes? Instead of all numbers I'd like to add in letters too.

Tequila
12-30-2011, 10:17 PM
You could try something like this:
http://911-need-code-help.blogspot.com/2009/06/generate-random-strings-using-php.html

I haven't read it all the way through. Need to get to bed, and stop playing with my MtG cards...

SilverDragonTears
12-30-2011, 11:40 PM
Where do I try to do this at?

Tequila
12-31-2011, 08:16 AM
That I'm not sure of. Probably somewhere in siggy.php.

SilverDragonTears
12-31-2011, 10:01 PM
I don't think so. I have no idea where though.

Tequila
01-09-2012, 01:40 PM
Somehow I think you need to get the code into the doadopt page... I've been trying but no luck.

SilverDragonTears
02-15-2012, 08:07 PM
HoF... any help on this?

Hall of Famer
02-17-2012, 05:44 AM
umm you mean owned adoptables id code? Just go to phpmyadmin and change the data type of field 'code' from int(11) to varchar(20) and you are good to go.

Tequila
02-22-2012, 11:24 AM
Tried that boss, not much has changed:

http://www.crystalhollow.com/siggy.php?id=1 (http://www.crystalhollow.com/levelup.php?id=1)

Hall of Famer
02-22-2012, 05:59 PM
Oh yeah you also need to modify the script that generates a random code, since the original one only gives you a 5 digit number without letters or symbols. Its doable, I will post a solution to this once I resolve SDT's breeding script glitch.

SilverDragonTears
02-24-2012, 05:26 PM
Can't wait for this!!

Hall of Famer
03-06-2012, 01:20 AM
I created a function that allows you to generate an alphanumeric code of any length. You can also enable/disable generation of symbols. This function will be included in the functions.php file for Mys v1.3.0 release, but you can have it now if you cant wait for this. The symbols list does not include all available symbols, since some mess up the script. But anyway, Id say at least 80% of symbols can be generated successfully with this function.

SilverDragonTears
03-07-2012, 01:17 AM
*makes grabby hands*

Hall of Famer
03-07-2012, 02:03 AM
Sent to your PM box already, the function will be available in Mys v1.3.0 anyway.

SilverDragonTears
03-07-2012, 03:36 PM
I must be missing some steps. It isn't working for me. Where do I put the example and do I need to change or add anything else?

Hall of Famer
03-07-2012, 03:39 PM
umm first of all, if you have a field called code in database, make sure its type is varchar instead of int, since the latter only accepts numbers. You will need to copy/paste the function passgenerator() into your functions.php file, and then call it whenever you want to generate an alphanumeric code.

SilverDragonTears
03-07-2012, 03:46 PM
Ok I see. But you never see that code. I guess I want the $aid to be letters.

Hall of Famer
03-07-2012, 04:11 PM
I see, the id to be letters? This can be done too, but a bit more complicated. First of all, you must disable the primary key auto_increment setting for this field. Next, edit the aid data type from phpmyadmin to make it varchar(15). The last thing to do is to use the following script, which you should not have problem with:


$aid = passgenerator(15,0)


Assume you do not want symbols in this field, since it is an id this should make sense. Be careful with what you do with adoptables id though, this field is predefined to be an auto-increment number and modifying this can lead to many potential problems in future.

SilverDragonTears
03-07-2012, 09:20 PM
I got it working but I had to remove the is_numeric part through out a lot of the scripts. Hope that wasn't very important :ooo:

Hall of Famer
03-09-2012, 07:49 AM
I dont suppose its important, since is_numeric() checks if a variable contains only numbers.