Report this

What is the reason for this report?

Uploading file/data using PHP and MYSQL not working

Posted on May 17, 2021

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

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

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

$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 ('testtest@gmail.com'); ");

?>

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.