I can access the old data but I am unable to add new data to the database.
The same code is working on localhost.
**There is no error message from the database/PHP, but because I am using “query check” before submitting the data code displays the error message → “Something went wrong, Please contact system administrator”(error message - if something went wrong during query execution).
** I can add data manually from PHPMyAdmin
The message “something went wrong” doesn’t really help. “Please contact system administrator” with no details a system administrator can do something with isn’t great advice.
If (for any reason) there is a problem during the query execution, then the code returns an error message “Something went wrong, Please contact system administrator” → A custom variable I created.
And I think I got it, It has something to do with default values in Table(In my case at least).
**Try adding default values to empty fields (in your database)
Admin can you check with other developers (I saw some similar posts yesterday)
We can’t help you if you don’t tell us anything. We need your code, an actual error message, and perhaps a URL as well. Oh, it would also be useful if you tell us what your trying to do.
It’s already mentioned in the post–>There is no error message from the database/PHP(not a visible one at least)
I used the in-built error function to check for any hidden error (because of the above), and got an error “no default value set for the field (with field name)”
That’s because you’re not checking for error messages. If mysqli_query returns false, then you can use mysqli_error to retrieve the error message. That message will provide a lot more information about why the query fails.
Which function and where do you use it? I don’t see it in the code.
We don’t even know what’s happening yet. We need the actual database query error for that. Only then can we maybe say something about why your query fails.
So what is the error message returned by mysqli_error right now?
Because if the default value issue was the only issue and has been completely fixed, your query would just work. Since it doesn’t, either your fix didn’t work or there is another issue.
Thank you, that error message provides a lot more information.
But it seems quite clear what the issue is, right? Your database table has a field val9 which does not have a default value, and you’re trying to enter a record it in which doesn’t have that value. Can you please verify that either the column has a default set or your query does try to write that column?