form validation

Thread Solved

Join Date: Jun 2005
Posts: 21
Reputation: planethax is an unknown quantity at this point 
Solved Threads: 0
planethax planethax is offline Offline
Newbie Poster

Re: form validation

 
0
  #11
Oct 5th, 2009
I have been able to correct the userid and username, and able to get drivers names in query by adding
value='$label'

Now, for some reason (no error) it seems to work, but just not being inserted into DB?
Thanx again.
Last edited by planethax; Oct 5th, 2009 at 2:34 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: planethax is an unknown quantity at this point 
Solved Threads: 0
planethax planethax is offline Offline
Newbie Poster

Re: form validation

 
0
  #12
Oct 5th, 2009
here is a sample of my input query echoed
INSERT INTO user_drivers(userid, username, driver1, driver2, driver3, driver4, driver5, driver6, driver7) VALUES('1','planethax','Carl Edwards','Greg Biffle',''Jeff Gordon', 'Jimmie Johnson', 'Juan Pablo Montoya', 'Mark Martin', 'Tony Stewart')
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: planethax is an unknown quantity at this point 
Solved Threads: 0
planethax planethax is offline Offline
Newbie Poster
 
0
  #13
Oct 5th, 2009
Originally Posted by planethax View Post
here is a sample of my input query echoed
Ya! I git it, if you look before Jeff Gordon, there was an extra '
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 55
Reputation: wilch is an unknown quantity at this point 
Solved Threads: 9
wilch wilch is offline Offline
Junior Poster in Training
 
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.
$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 ?
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 21
Reputation: planethax is an unknown quantity at this point 
Solved Threads: 0
planethax planethax is offline Offline
Newbie Poster
 
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.
Last edited by planethax; Oct 6th, 2009 at 10:01 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 55
Reputation: wilch is an unknown quantity at this point 
Solved Threads: 9
wilch wilch is offline Offline
Junior Poster in Training
 
1
  #16
Oct 6th, 2009
Cool, that's good news then.
umm.. by the way how do you do it ?
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 764 | Replies: 15
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC