Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update loop problem 1

Status
Not open for further replies.

clivehenderson

IS-IT--Management
Nov 2, 2002
66
GB
I have an update statement that updates a field in each record in a recordset to a random value using a function.

The problem is that it creates a random number for the first receord and carries on using it for all the others.
Iss there a way of forcing the statement to call the function freshly each time or am I missing something fundamental?
Any help appreaciated

The statement is like this:
Thanks
Clive


Code:
UPDATE tblMembers2 SET tblMembers2.mSecKey= tNG_generateRandomString(16) WHERE tblMembers2.mID>0;
 
what happens is you call tng_generaterandomstring multiple times;
I thought it might be sonmething to do with the where clause getting the roes and then applying the first value it got to all rhe mSecKey in the resuklt set. I playted with rand() which generates a different value each time.
Can you try using rand(), you might have to fiddle with the convert() or cast() functions to get it to work though
 
Hi

ingresman, take a look at clivehenderson's previous thread434-1526839. tng_generaterandomstring() seems to be a PHP function, so it is called only once when composing the string with the SQL query.

It would be better to rewrite it in MySQL. ( Visit forum436 for help. )

Feherke.
 
Code:
$sql = "UPDATE tblMembers2 SET tblMembers2.mSecKey= ".tNG_generateRandomString(16)." WHERE tblMembers2.mID>0;";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top