Cannot add new data in php myadmin

Solution please! I can’t add new data through my website, even though everything is in accordance with the php function. and all databases are appropriate and can display data from php myadmin but if I input data an error will occur. then i try again on localhost , everything works but i upload again to hosting an error occurs

Perhaps try using the template next time.

What is your URL?
What is the error message?
What is your code?

can’t add data through my website

try putting mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); into your file. it shows mysql errors

What error? What do you see? Can you share the error message?

Please try checking the output of the mysqli_query function. It returns true or something true-like if the query was successful, and false if the query failed. If the query failed, you can get the error message using the mysqli_error function.

Also, somewhat unrelated, it’s good that you’re escaping the input data before sending it to the database (most code snippets we see here don’t have that, leaving them wide open to SQL injection attacks), but htmlspecialchars is not designed for cleaning database input, and may still leave you vulnerable. The function mysqli_real_escape_string is what you should be using instead.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.