Cannot connect Local Database from Wordpress Elementor

Issue Summary

I have code in the functions.php file, of a Theme (woostify) that I am using in Worpress. I add shortcode to Elementor, to connect to the functions.php file so that I can connect to the database. I get “Internal Server error” Note, I can connect Elementor, to the functions.php file but not connect to the database.

One or two sentence summary of the issue.
The code I added,


to the functions.php file is:
function databasetest_check( $atts ) {
$servername = “10029”;
$username = “root”;
$password = “root”;
$dbname = “dbtest”;

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully ";
}
add_shortcode( ‘db_short’, ‘databasetest_check’);

Troubleshooting Questions

  • Does this happen for all sites in Local, or just one in particular? All sites

  • Are you able to create a new, plain WordPress site in Local and access it in a Browser? yes

Replication

Describe the steps that others can take to replicate this issue. If you have screenshots that can help clarify what is happening, please include them!

System Details

  • Which version of Local is being used? 6.0.1

  • What Operating System (OS) and OS version is being used? Windows 8.1

    • For example: macOS Catalina or Windows 10 Professional
  • Attach the Local Log. See this Help Doc for instructions on how to do so:

Security Reminder

Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there’s always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn’t private info like passwords being displayed.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.