gongpex Posted April 6, 2014 Author Share Posted April 6, 2014 Hello all, I think this code, is what did you mean (mysqli_error()) <?php require("connect_db.php"); mysqli_query($connect,"SELECT * FROM member"); $user = $_POST['test']; $name = $_POST['num']; $ins = mysqli_query($connect,"INSERT INTO member(m_name,m_user) VALUES ('$name','$user')"); if(!$ins) { printf ("Errormessage %s n",mysqli_error($connect)); } else { printf ("recorded"); } ?> this code result : Errormessage Field 'm_pass' doesn't have a default value Q : how to fix this problem ? please help thanks Link to comment Share on other sites More sharing options...
thescientist Posted April 7, 2014 Share Posted April 7, 2014 did you try to even look up the error message?? https://www.google.com/search?q=field+doesn%27t+have+a+default+value+mysql&oq=field+doens%27t+hav&aqs=chrome.2.69i57j0l5.3174j0j7&sourceid=chrome&espv=2&es_sm=119&ie=UTF-8 sounds like that field in your table can't be NULL. Link to comment Share on other sites More sharing options...
gongpex Posted April 8, 2014 Author Share Posted April 8, 2014 hello, you right, it can be recorded after giving default value. many thanks about this, but about : sounds like that field in your table can't be NULL. Q : yes, but I wonder, why it can be occurs? when I use old PHP version with using mysql not mysqli it can be record without giving default value. please explain to me thanks again Link to comment Share on other sites More sharing options...
justsomeguy Posted April 8, 2014 Share Posted April 8, 2014 That's not an error from the PHP API, that's an error from the actual database. You would get that same error using any API. Link to comment Share on other sites More sharing options...
gongpex Posted April 9, 2014 Author Share Posted April 9, 2014 (edited) That's not an error from the PHP API, that's an error from the actual database Q : so, I must change with other database or database version to avoid this error? thanks Edited April 9, 2014 by gong Link to comment Share on other sites More sharing options...
justsomeguy Posted April 9, 2014 Share Posted April 9, 2014 No, you need to follow the rules that you set for your database. You have a field that doesn't have a default value, and you're not including it in the insert query. That is an error, you need to understand what that error means. The field doesn't have a default value and you aren't giving it a value, so the database doesn't know what value to use for that field, and that's an error. Either change your query to include that field or change the table structure to give it a default value. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now