Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-26-2007, 08:08 PM   PM User | #1
BigBob
New to the CF scene

 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
BigBob is an unknown quantity at this point
Data disappears

I'm currently having problems with a gaming ladder script and specifically the register/validate part.

A player will register and will have to validate via a code sent in e-mail. The username etc. are stored in the table 'validate'. Once validated the username etc. should be transferred to the 'users' table but this doesn't happen.

The data is deleted from the 'validate' table but doesn't appear in 'users'

The code can be seen at:

http://pastebin.com/936959

Any ideas?
BigBob is offline   Reply With Quote
Old 06-26-2007, 09:08 PM   PM User | #2
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
Before Fumigator has the opportunity (), why are you not validating your query with die(mysql_error())?

It may show you why you are not inserting data (and hence, its disappearance) the way you are expecting.
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Old 06-26-2007, 09:20 PM   PM User | #3
BigBob
New to the CF scene

 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
BigBob is an unknown quantity at this point
Added that in and it says:

Error: Column count doesn't match value count at row 1
BigBob is offline   Reply With Quote
Old 06-26-2007, 09:28 PM   PM User | #4
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
That's why you are "losing" data. There is a missing (or extra) column in one of your SQL statements, causing the statement to fail.

Look over your SQL and make sure that you have the right number of columns in your INSERT.

FOR EXAMPLE:

If mytable has 13 columns, INSERT INTO myTable VALUES () needs to have 13 values in it, while INSERT INTO myTable (col1,col2,col3) VALUES () only needs to have 3 values in it.
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Old 06-26-2007, 09:28 PM   PM User | #5
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Quote:
Before Fumigator has the opportunity ( ), why are you not validating your query with die(mysql_error())?
Oh man that made me laugh. You caught on to my mantra
__________________
Fumigator is offline   Reply With Quote
Old 06-26-2007, 09:34 PM   PM User | #6
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
Figured you needed a good chuckle.
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Old 06-26-2007, 09:39 PM   PM User | #7
BigBob
New to the CF scene

 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
BigBob is an unknown quantity at this point
Quote:
Originally Posted by Daemonspyre View Post
That's why you are "losing" data. There is a missing (or extra) column in one of your SQL statements, causing the statement to fail.

Look over your SQL and make sure that you have the right number of columns in your INSERT.

FOR EXAMPLE:

If mytable has 13 columns, INSERT INTO myTable VALUES () needs to have 13 values in it, while INSERT INTO myTable (col1,col2,col3) VALUES () only needs to have 3 values in it.
Cheers. I didn't code the script myself.

I added extra ones in make them equal but still get the same error.

1. I'm guessing the coder put NULL in first as that would be the 'ID' column and is auto_increment. Would I be right?

2. The last two fields are showing the attributes 'UNSIGNED'. Would this make a difference at all?

I recently integrated the ladder with a forum so this is where the extra fields came from.


EDIT: Okie. Not having a good day. I was saving the file but then uploading the original one again. Did it 4 times before I reliased. It's now working. Thanks for the help! Rep given.

Last edited by BigBob; 06-26-2007 at 09:43 PM..
BigBob is offline   Reply With Quote
Old 06-26-2007, 09:50 PM   PM User | #8
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
1. You would be correct

2. UNSIGNED means that the column will only accept numbers and will not accept negative numbers. Default for these is usually NULL or 0.

Before you go adding columns to your scripts/tables, why not change your INSERT statements to include the field names?
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Old 06-26-2007, 09:54 PM   PM User | #9
BigBob
New to the CF scene

 
Join Date: Jun 2007
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
BigBob is an unknown quantity at this point
Quote:
Originally Posted by Daemonspyre View Post
1. You would be correct

2. UNSIGNED means that the column will only accept numbers and will not accept negative numbers. Default for these is usually NULL or 0.

Before you go adding columns to your scripts/tables, why not change your INSERT statements to include the field names?
Check my edit to last post ;-)
BigBob is offline   Reply With Quote
Old 06-26-2007, 09:55 PM   PM User | #10
Daemonspyre
Regular Coder

 
Join Date: Mar 2007
Posts: 505
Thanks: 1
Thanked 19 Times in 19 Posts
Daemonspyre is on a distinguished road
Sorry! Didn't see the EDIT till after.

Thanks for the REP!
__________________
Quote:
To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
Please, if you found my post helpful, pay it forward. Go and help someone else today.
Daemonspyre is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:19 AM.


Advertisement
Log in to turn off these ads.