Im trying to get my database for my local host up and running using MYSQLI and i get the message "Failed to connect: A connection could not be established because the destination computer actively refused it"
My code is the following
the connect page called connect.php
<?php
require_once "user_db.php";
$mysqli = mysqli_connect($servername,$username,$password,$database);
if (mysqli_connect_errno()) {
echo "Failed to connect:",mysqli_connect_error();
}
function performQuery($sql) {
global $mysqli;
$result = mysqli_query($mysqli,$sql);
if ($result) {
return $result;
} else {
echo "Something went wrong";
}
}
?>
and in adition to that i have the user_db.php page with my database information
<?php
$servername = "localhost";
$username = "root";
$password = "12345";
$database = "recovery"
?>
and then the page where i try to add stuff to my database
<?php
require_once "DB_handling/connect.php";
if(isset($_POST["submit"])) {
$duration = $_POST['TD'];
$intensity = $_POST['TI'];
$RPE = $TI*$TD;
$New = performQuery("INSERT INTO rpe(duration, intensity, rpe) VALUES ('$duration', '$intensity', '$RPE')");
}
?>
with a simple form field to get the values
<form class="" action="insert.php" method="post">
Training Intensity
<input type="number" placeholder="1-10" name="TI">
<br>
Training Duration
<input type="number" placeholder="in minutes" name="TD">
<br>
<input type="submit" name="submit" value="Submit">
</form>
Im using MAMP as my localhost server
Does know how to fix the problem. Thanks in advance