943,985 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1245
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Oct 5th, 2009
0

Re: form validation

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.
Reputation Points: 10
Solved Threads: 0
Light Poster
planethax is offline Offline
34 posts
since Jun 2005
Oct 5th, 2009
0

Re: form validation

here is a sample of my input query echoed
Quote ...
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')
Reputation Points: 10
Solved Threads: 0
Light Poster
planethax is offline Offline
34 posts
since Jun 2005
Oct 5th, 2009
0
Re: form validation
Click to Expand / Collapse  Quote originally posted by planethax ...
here is a sample of my input query echoed
Ya! I git it, if you look before Jeff Gordon, there was an extra '
Reputation Points: 10
Solved Threads: 0
Light Poster
planethax is offline Offline
34 posts
since Jun 2005
Oct 6th, 2009
1
Re: form validation
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.
Reputation Points: 21
Solved Threads: 15
Junior Poster in Training
wilch is offline Offline
76 posts
since Aug 2007
Oct 6th, 2009
0
Re: form validation
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
planethax is offline Offline
34 posts
since Jun 2005
Oct 6th, 2009
1
Re: form validation
Cool, that's good news then.
Reputation Points: 21
Solved Threads: 15
Junior Poster in Training
wilch is offline Offline
76 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Code.......
Next Thread in PHP Forum Timeline: Uploading media files trouble...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC