ryanzroost Posted November 21, 2006 Share Posted November 21, 2006 I am trying to insert a simple randomly generated key into a database and for some reason I can't get it to work. I have provided the code below. Help me please! <input type="hidden" name="Userhc15_ProjectNumber" id="Userhc15_ProjectNumber" value="<?php echo KT_escapeAttribute($row_rshavecopy15['Userhc15_ProjectNumber']);function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++) { if(isset($key)) $key .= $pattern{rand(0,35)}; else $key = $pattern{rand(0,35)}; } return $key;} ?>"/> Link to comment https://forums.phpfreaks.com/topic/27993-random-key-in-mysql-database/ Share on other sites More sharing options...
taith Posted November 21, 2006 Share Posted November 21, 2006 [code]<?function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyz"; for($i=0;$i<$length;$i++){ $key .= $pattern{rand(0,35)}; } return $key;}?>[/code] Link to comment https://forums.phpfreaks.com/topic/27993-random-key-in-mysql-database/#findComment-128037 Share on other sites More sharing options...
ryanzroost Posted November 21, 2006 Author Share Posted November 21, 2006 I tried to insert the code but it still didn't work. Would it help if I sent you all of the code, or is there anything else you need to know about what I am doing? I am fairly new at this. Link to comment https://forums.phpfreaks.com/topic/27993-random-key-in-mysql-database/#findComment-128065 Share on other sites More sharing options...
taith Posted November 21, 2006 Share Posted November 21, 2006 [code]<?function randomkeys($length){ $pattern = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; for($i=0;$i<$length;$i++){ $key .= $pattern{rand(0,62)}; } return $key;}?><input type="hidden" name="Userhc15_ProjectNumber" id="Userhc15_ProjectNumber" value="<?=KT_escapeAttribute($row_rshavecopy15['Userhc15_ProjectNumber'])?>"/><?=randomkeys(10)?>[/code] Link to comment https://forums.phpfreaks.com/topic/27993-random-key-in-mysql-database/#findComment-128068 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.