dty5753 2018-10-15 23:09
浏览 138

无法连接到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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)