Georgezx9 Posted October 30, 2014 Share Posted October 30, 2014 Hi cracking book by the way, learned loads. I get an error when I try and register (Chapter 18), the error is: An error occurred in the script f:\sites\register.php on line 63 query: Insert into users email, pass, first_name, last_name etc etc It then states : MYSQL Error : Unknown column 'first_name' in 'field list' I know the SQL database has this field name correctly spelled the same as the PHP. Help, spent ages looking? GY Link to comment Share on other sites More sharing options...
HartleySan Posted October 31, 2014 Share Posted October 31, 2014 Can you please provide some more code (without providing too much)? Thanks. Link to comment Share on other sites More sharing options...
Georgezx9 Posted October 31, 2014 Author Share Posted October 31, 2014 Some of the error is given below, the only difference is the order, but that should not matter. the actual code is exactly as the download from Larrys site. The database is set up using the code from the book, and appears correct. An error occurred in script 'F:\Sites\register.php' on line 63: Query: INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('1@2.com', SHA1('zzzzzzzz'), 'xx', 'yy', '38f7125efa20dccb8da938bd95cdda1e', NOW() ) MySQL Error: Unknown column 'first_name' in 'field list' Date/Time: 10-30-2014 16:18:05 Array ( [_GET] => Array ( ) [_POST] => Array ( [first_name] => xx [last_name] => yy => 1@2.com [password1] => zzzzzzzzzzz [password2] => zzzzzzzzzzz [submit] => Register ) Link to comment Share on other sites More sharing options...
HartleySan Posted October 31, 2014 Share Posted October 31, 2014 And could you please copy and paste the structure of your users table into a post as well? Thanks. Link to comment Share on other sites More sharing options...
Georgezx9 Posted October 31, 2014 Author Share Posted October 31, 2014 Not sure of best way to do it, so exported it to CSV and cut and pasted from there. No data in it yet, as I was trying to register first user. Thanks in advance user_id first_name last_name email pass user_level active registration_date Link to comment Share on other sites More sharing options...
HartleySan Posted October 31, 2014 Share Posted October 31, 2014 What happens when you execute the following query directly on the DB? INSERT INTO users (email, pass, first_name, last_name, active, registration_date) VALUES ('1@2.com', SHA1('zzzzzzzz'), 'xx', 'yy', '38f7125efa20dccb8da938bd95cdda1e', NOW()); Also, is user_level a required field? Link to comment Share on other sites More sharing options...
Georgezx9 Posted October 31, 2014 Author Share Posted October 31, 2014 It correctly adds the data to the database! Link to comment Share on other sites More sharing options...
HartleySan Posted November 1, 2014 Share Posted November 1, 2014 So you problem is somewhere else in the code. Link to comment Share on other sites More sharing options...
Georgezx9 Posted November 1, 2014 Author Share Posted November 1, 2014 I know, but the code is exactly as downloaded from larrys website Link to comment Share on other sites More sharing options...
Georgezx9 Posted November 1, 2014 Author Share Posted November 1, 2014 Just downloaded the code again and it works, not sure what it was probably something I had done, but thanks for help anyway Link to comment Share on other sites More sharing options...
HartleySan Posted November 1, 2014 Share Posted November 1, 2014 Yeah, these things happen, so don't sweat it. It's all part of the learning process. Link to comment Share on other sites More sharing options...
Recommended Posts