| | |
form validation
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Aug 2007
Posts: 55
Reputation:
Solved Threads: 9
1
#14 Oct 6th, 2009
Hi Planet,
The reason why the insert could be failing is because the db expects the userid to be an integer, whilst in your case if you are using the following code to generate your userid, then the id wont be an integer but rather a 7 character string.
What you can rather do is, make the userid column, an auto incrementing column, then create another column say - userkey, which stores the 7 character string. Then, modify your insert query to accommodate the new userkey field, and then remove the auto incrementing column(userid):
Note: the userid has been replaced by userkey in the query. The userid will auto increment itself.
The reason why the insert could be failing is because the db expects the userid to be an integer, whilst in your case if you are using the following code to generate your userid, then the id wont be an integer but rather a 7 character string.
$randID = substr(md5(microtime(), -7)); What you can rather do is, make the userid column, an auto incrementing column, then create another column say - userkey, which stores the 7 character string. Then, modify your insert query to accommodate the new userkey field, and then remove the auto incrementing column(userid):
$userkey = substr(md5(microtime(), -7));
$sql = "INSERT INTO user_drivers(userkey, username, driver1, driver2, driver3, driver4, driver5, driver6, driver7) VALUES('".$userkey."','".$username."','".$drivers[0]."','".$drivers[1]."',''".$drivers[2]."', '".$drivers[3]."', '".$drivers[4]."', '".$drivers[5]."', '".$drivers[6]."')";Note: the userid has been replaced by userkey in the query. The userid will auto increment itself.
umm.. by the way how do you do it ?
•
•
Join Date: Jun 2005
Posts: 21
Reputation:
Solved Threads: 0
0
#15 Oct 6th, 2009
Ahhh, sorry I was not clear, I did get it to work now, it was not inserting before because I had an extra ' in my query (just before Jeff Gordon in my sample)
The reason I am not auto incrementing the userid, is the ID is already set in another spot of my site.
(I have remove the code snippet from earlier to creat a unique ID as I had realized later I could use the one already assigned)
Thanx for all your help, I am starting to get this now.
The reason I am not auto incrementing the userid, is the ID is already set in another spot of my site.
(I have remove the code snippet from earlier to creat a unique ID as I had realized later I could use the one already assigned)
Thanx for all your help, I am starting to get this now.
Last edited by planethax; Oct 6th, 2009 at 10:01 am.
![]() |
Similar Threads
- PHP Form Validation ??? (PHP)
- sample code for form validation using ajax (JavaScript / DHTML / AJAX)
- javascript Form Validation Libraries (JavaScript / DHTML / AJAX)
- PHP Mail Form Validation - Help Please? (PHP)
- coldfusion form validation question (ColdFusion)
- Really Stuck - ASP/Javascript Form Validation (ASP)
- Dreamweaver php form validation and redirect (PHP)
- Help on form validation requested. (PHP)
- uregnt need of form validation (JSP)
Other Threads in the PHP Forum
- Previous Thread: PHP Code.......
- Next Thread: Uploading media files trouble...
Views: 764 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access address ajax apache api array autoincrement beginner binary broken cakephp checkbox class cms code cron curl database date dehasher directory display download dynamic echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail menu method methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query question radio random recursion regex remote script search select server sessions sms soap source space speed sql structure support! syntax system table tutorial update updates upload url validation validator variable video web xml youtube





