And avoid error message “WARNING: cannot start the portable MySql server…” when executing application.
Application does proceed but, as expected, when trying to use MySQL get “PHP Fatal error: Uncaught Error: Call to a member function query()”.
Connection can fail, for multiple reasons (conflict, user error, user messed with mysql folder, etc.). I would like to know if it’s not connected and, thereby, have my code use another process other than SQL.
I looked at the forum for possible solutions such as an HESscript, global variable, etc. No luck.
1 Like
Unfortunately, it’s not possible to disable the warning, but we added your request to our TODO list for the future update (there will probably be a new global variable that can suppress this warning).
1 Like
For ExeOutput for PHP 2024, will we be able to check if MySQL server is connected (or not)?
I looked at the 2024 documentation but couldn’t find anything.
I too had requirements for checking on mySQL server status. Could not find anything in docs. Ended up using code like in text file here:
https://urhost.net/gdg-files/mysql-check.txt
Unfortunately, mods have this forum locked down and simple users cannot add code with php tags.
This of course is not meant to replace the answer to your question that admin should address, only sharing what worked for me
1 Like
In ExeOutput for PHP 2024, you can indeed check whether a MySQL server is connected or not by using standard PHP functions that interact with MySQL. Since ExeOutput for PHP compiles your PHP applications into standalone Windows applications, the PHP code you use to interact with MySQL servers functions in the same way as it would on a typical PHP server setup.
To check if a MySQL server is connected, you can use the following PHP code snippet:
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>
This code attempts to connect to a MySQL server with the specified credentials. If the connection fails, it will output “Connection failed” along with the error message; if it succeeds, it will echo “Connected successfully.”
Add this code to the homepage script of your app.