Uploading file/data using PHP and MYSQL not working

Hi there, this is probably a basic question but I cannot find the answer on google and StackOverflow

I already install the PHP and MYSQL in my droplet. Displaying data from my database is working, I can able to display the data from my database on my website, and even update query, and delete query using PHP and MYSQL. But the problem is, adding data is not working.

Here’s my test code

$db = mysqli_connect("localhost", "xxxx", "XXXXX", "xxxxx");

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();

$admin_accounts = mysqli_query($db, "SELECT * FROM admin_accounts");

while ($row = mysqli_fetch_array($admin_accounts)) {
	echo "<br />" . $row['email'];

mysqli_query($db, "INSERT INTO admin_accounts (email) VALUES (''); ");


INSERT INTO query is not working but I tested the UPDATE query and DELETE query it’s working, please help me out of this problem.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there @micronicsphils,

It sounds like that your MySQL user does not have insert privileges.

You could try granting all privileges for the MySQL user that you are using to the MySQL database that you are using:

GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_user'@'%' WITH GRANT OPTION;

Let me know how it goes! Regards, Bobby