I recently got suspended for going over mysql usage. I want to know why, as I just made a test connection to my mysql server to make sure everything works the way I want it to. I would love if someone told me why it went over the usage limits when ( I believe) I used so little usage. Here’s the code:
<?php
//Replaced the login credentials because I don't want them publicaly visible
$servername = "server";
$username = "Username";
$password = "Password";
try {
$conn = new PDO("mysql:host=$servername;dbname=epiz_25232296_feedback", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
try{
$sh = $conn->prepare( "DESCRIBE `test`");
if ( $sh->execute() ) {
// my_table exists
}
else {
// my_table does not exist
$sql = "CREATE TABLE test (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
test CHAR
)";
// use exec() because no results are returned
$conn->exec($sql);
echo "Table created successfully";
}
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
try{
$sql = "INSERT INTO test (test)
VALUES ('J')";
// use exec() because no results are returned
$conn->exec($sql);
echo "New record created successfully";
} catch(PDOException $e) {
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
?>
Every time you refresh the page, tweak some code or just open the tab, it may reload and refresh, so everytime you would check if it works, you send a query and each query, counts as some mysql, or if your code wasn’t optimized, it may not be efficiently transferring data
There’s my answer, yes. But I only did this about 20 times. If 20 people or more were to visit my website, it would be suspended. This seems like a very low usage then.
Well, rather than say query the database, as @katufo says, everytime you reload you create a new table, which needs more storage, wheras when only querying the server with (What is in this table?) you are creating a table.
I can’t really explain
Plus you might just have been the only one creating a table and the system spotted you
You can’t actually create another table with the same name otherwise it gives you an error. I put in some code that checks if the table exists. I’m only putting in one thing into the table. I want to categorize about 150 items with mysql, and I am worried this would be way too much for the “free unlimited hosting” plan. I don’t want to buy premium just yet
I guess that would work, but I want to also have an admin page where you can add categories for a new item (which would create a new table). If I visit the page 20 times, and make about 60 queries total (On average I made 3), I am worried what would happen if only a handful of people visit my website that queries about 60 items from the table.
Like i say, querying uses up a lot less of everything, as you just have to;
Locate Server => Authenticate => Find Database => Show Info
But with writing you have to
Locate Server => Authenticate => Find Database => Locate Where to insert => Open Channel => Send Data => Recieve Data => Encrypt Data => Return Message/Error
Basically querying only is fine, but like i say, you might just have been unlucky to be the only one, My support can only stretch this far.