无法连接到IIS上的mySql

So I need to do something for work which is to simply take a users name/last name/email and store it to a database.

As a simple test, I put this in my connect file php:

$server="localhost";
$uname="root";
$pass="PASSHERE";
$db = "DBNAMEHERE";

$c2d = mysqli_connect($server, $uname, $pass, $db) or die("Failed to connect to database yo" . mysqli_error($c2d));

if($c2d){
    echo "connection made";
}else{
    echo "connection NOT made";
}

This above works when I run it from WAMP locally or from my test live server on Godaddy etc. Now, the issue is that the production environment is an IIS box to which I installed Apache on it via the IIS tool. It's my first time working with IIS so....Just trying to figure things out But need a bit of assistance

For some reason, when I drag and drop the working file from my local machine to the production one for testing, the connection can never be made. It's always erroring out.

I've done a bit of digging around but to no avail. I've tried different connection strings, ive tried messing with the PHP.ini file on the IIS box, ive tried other simple examples but again it always fails. After doing some research and reading random posts here on SO, I came across another post that essentially said to make sure that "mysqli" extension was enabled in php.ini and it is.

Lastly, since i dont have a lot of time to get this working, I figured instead of saving to a database, id write locally to a file(csv and/or text file), with something like:

$putContentsIntoCSV = fopen("001registrations.csv", "a");

$putContentsIntoTXT = file_put_contents("001regtext.txt", $insertDataToText, FILE_APPEND);

    if($putContentsIntoCSV && $putContentsIntoTXT ){
        http_response_code(200);
        setcookie("success", true);
        echo "Your data has been saved!";
        fputcsv($putContentsIntoCSV, $insertData);
        fclose($putContentsIntoCSV);
    }else{
        http_response_code(400);
        echo "no connection";
    }

and that too works in my local env. and my Godaddy server, but as soon as i drop it inside IIS/apache, it doesnt work. To be clear, PHP works, but the functionality im needing doesnt.

Im pretty much stuck not sure what else to try. Any help is greatly appreciated.