I was wondering if anyone could help me out with this problem. I have a script that has a bunch of code in it. For some reason the coder decided to use a hex for a id number (it's just a member number, nothing secret) anyway the code section that I want to change is this : -
function createUniqueID($table, $column)
-
{
-
$maxTries = 10;
-
-
while(1)
-
{
-
if($maxTries <= 0)
-
return false;
-
-
$uniqueID = substr(md5(uniqid(rand(), true)), 0, 8);
-
-
// check if this token does not exist in the table already
-
$sql = "select $column from $table where $column="._q($uniqueID);
-
$rs = (directory where code is located)::execute($sql, __FILE__, __LINE__);
-
if(!$rs)
-
{
-
showMsg(L_G_DBERROR, 'error');
-
return false;
-
}
-
-
if($rs->EOF)
-
return $uniqueID;
-
-
$maxTries--;
-
}
-
-
return false;
-
}
-
I just want a 5 digit sequential number. Can someone tell me how to change this. I realize that auto_increment would work in the db, but, there is so much code that interrelates in the script I don't believe that removing this string would work properly. Thanks for any help.
24 9380
Your coder didn't use hex directly -- that's coming from the hashing function md5 which changes substantially as the input changes. If it's not something that has to be hidden why not add a 5 digit number to the db id?
For example, if you consistently add 50000 to the id, the number will always be 5 digits (unless your number of members causes it to go to 6 digits, of course).
Your coder didn't use hex directly -- that's coming from the hashing function md5 which changes substantially as the input changes. If it's not something that has to be hidden why not add a 5 digit number to the db id?
For example, if you consistently add 50000 to the id, the number will always be 5 digits (unless your number of members causes it to go to 6 digits, of course).
Hi Jeremy,
Thank you for your response. My problem is that my member ids are coming like "3e45jk1p" what I want is for them to start at 1 and proceed sequentially from there. I don't necessarily need each id to be 5 digits long. I would just expect that I would not need to exceed 5 digits.
Oh, then either:
1) Use the current autoincrement field's value, or
2) create a new autoincrement field and use it's value.
If you're just using the value of the field, then #1 is the preferred way as #2 creates unnecessary duplication.
So do I do that by just saying "$uniqueID=auto _increment" ? If so What if I want to start at ID, say 1001, how would I do that?
Well, you have to get the autoincrement field from the database and use that. If you want to start at some number, then I'd recommend using the addition that I recommended above in case there are any DB tables which rely on the current values in your database.
Ok, I'll just start at 1 then. I appreciate the help Jeremy, but, I'm about as lost as I can be. Given that I have the above code now, what do I do to change it?
If you provide the database table structure, I could be of greater help there. PHPMyAdmin is available (or installable) in most places and exports the DB structure very nicely.
Thanks Jeremy. There are 32 tables on the db. The only 2 that I think that are relevant are the account table and the user table. The user table is basically the account table plus extra info for address, etc. Here is the structure for the account table: -
CREATE TABLE `wd_g_accounts` (
-
`accountid` varchar(8) NOT NULL default '',
-
`name` varchar(100) NOT NULL default '',
-
`description` text,
-
`dateinserted` datetime NOT NULL default '0000-00-00 00:00:00',
-
`rstatus` tinyint(4) NOT NULL default '0',
-
PRIMARY KEY (`accountid`),
-
UNIQUE KEY `name` (`name`),
-
UNIQUE KEY `IDX_wd_g_accounts1` (`accountid`)
-
) TYPE=MyISAM;
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Jenn L |
last post by:
I have a database that is pre-populated with sequential part numbers.
As people reserve the parts I update a flag to show the # is no longer
available. Now they want the ability to take out a block of "x"
number of sequential part numbers - say for example 5.
If my database had the following numbers available:
101
104
105
110
|
by: allyn44 |
last post by:
Hello,
I have a situation where I have to create 20 labels for each instance of an ID-each of the 20 labels
has a different test number on it but needs the same id and one of 3 project names--for each label I
need:
ID number
Project name (there are currently 3 but will be more in the future)
Test number: There are 20 different tests for each ID number
|
by: GAVO. |
last post by:
Hello every one
I have a database with a form called "frmOrders" on that for I need to
create a sequential number for each city apart from the original autonumber.
So the table "tblorders" would look something like this:
OrderID (Autonumber) SeqNo City
1 1 London
2 1 Madrid
3 ...
|
by: James |
last post by:
Hello there,
Does anyone know how to create a sequential
record number field in a query??
Thanks,
James
|
by: NomoreSpam4Me |
last post by:
Hi there i have a little problem with my invoice.
Here it is:
i have a main menu with buttons, one of my button is "Create new
invoice", when click on it a form pop up so i can enter my information
and one of the field (the user cannot change the info in it.) is
invoice #. Right now, everythime i click on "Create new invoice", the
invoice # add 1. But my problem is sometime the employee dont fill it
(for x reason) and shut it down,...
| |
by: Mike Kingscott |
last post by:
Hi all,
I'd building an app that posts to a web service. One of the things
that is required in the soap header is a sequential number appended to
a ref, i.e. "IGI1001", "IGI1002", etc.
Obviously the first part of the reference ("IGI") stays the same, but
I need an incrementing number generated. Now, I was thinking of doing
this via a SQL database, but it would be an awful waste as there would
only be one table and one stored procedure...
|
by: Nooby |
last post by:
New to Access here. I inherited a db that has the first column as an
automatically generated sequential number. I want to bump it up, but
for the life of me I can't figure out how to do it. Is this type of
generation a built in function of Access? I'm sure it can be written
manually, but I doubt someone took the trouble to do it...
Can someone point me in the right direction to figure out how to change
this number?
Thank you one and all!...
|
by: maxamis4 |
last post by:
Hello folks,
I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone numbers. with in that subform the user has the ability to select between to radio buttons to do a bulk selection. The first option lets the user select the first X amount of numbers that he or she wants. The second option selects X amount of numbers but...
|
by: Axxe |
last post by:
I have searched high and low for cogent, well-explained coding to complete a project on which I have spent six months of work.
I stumbled across something on this site that is close to what I seek, but, as is rather typical, I could understand neither the question nor the answer.
I am hopeful that someone in this forum can provide me with suitable guidance.
THE ISSUE
I am working in Access 2003. The database I am preparing...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |