I have an SQL database hosted on Bluehost - very simple set up with 2 columns:
Using the following php code to pull a variable called, 'status' from the URL and write it to the database:
<?php
$servername = "localhost";
$username = "myusername";
$password = "mypassword";
$dbname = "pi_test_data";
$conn = new
mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("connection failed: "
. $conn->connect_error);
}
$sql = "INSERT INTO pi_test_data (status) VALUES ('$_GET[status]')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "
<br>" . $conn->error;
}
$conn->close();
?>
There are only 2 options to update the status column:
Posting data to the Status column via URL will work twice then seems to freeze for an undetermined period of time (my tests estimate that I'm locked out for about 5 minutes). After that lock-out period, I can post twice again, then get locked out, etc etc. Even when I'm locked out, my PHP code will return, "New record created successfully" but the database will not update.
Adding data to the database via SQL code in phpMyAdmin works fine, I can write a seemingly unlimited number of records without the database freezing or locking me out.
I've added my PC IP address and the IP address of the URL I'm using to post the data to Remote Mysql Database Access settings in Bluehost.
I've had a lot of fun on this project but this piece of the puzzle has been driving me crazy for a couple of weeks - I keep coming back to it between problems and can never make any progress. Can someone in the community please help, or at least point me in the right direction? Thank you in advance for your help!