如何将我托管的php网站连接到我本地服务器上的sql server数据库 [英] How to connect my hosted php website to sql server database on my local server

查看:91
本文介绍了如何将我托管的php网站连接到我本地服务器上的sql server数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个PHP网站,后端是MS SQL 2012,我使用XAMPP作为我的开发Web服务器。如果我的网站是内网使用它完全可以工作,如连接到数据库,但当我托管到 1an1.com 时,它给了我这个错误:

I developed a PHP Website and backend is MS SQL 2012 and I used XAMPP as my development web server. If my website is intranet used it totally works such as connecting to database but when I hosted it to 1an1.com, it gives me this error:

Call to undefined function sqlsrv_connect() in dbconn.php on line 9.



这是我的数据库连接:


Here's my database connection:

<?php

    $serverName='xxx.xxx.00.xx'; //<-- should I include PORT here?
    $connectionInfo=array(
                    'Database'=>'DBName',
                    'UID'=>'userName',
                    "PWD"=>'Password');

    $conn = sqlsrv_connect($serverName,$connectionInfo); //<-- line 9 here

    if($conn){
        //echo 'Connection Established!<br />';
    }else{
        //echo 'Connection Failed!<br />';
        die(print_r(sqlsrv_errors(),TRUE));
    }

?>



实际上,我是困惑使用什么..比如,我应该在这里使用IIS还是其他程序但是为了开发,我用XAMPP来测试我的网站。



或者是否可以使用XAMPP在这里?用于连接我的web托管的php网站和我的ms sql数据库?



我对这种东西很新,所以如果你能为我提供一些一步一步的文章,我会非常感激。



提前致谢


Actually, I'm confused what to use.. like,should I use IIS here or other procedures but for development, I used XAMPP to test my website.

Or is it possible to use XAMPP here? for connecting my web hosted php website and my ms sql database?

I'm new with this kind of stuff, so if you can provide me some step by step articles for this is much more appreciated.

Thanks in advance

推荐答案

serverName = ' xxx.xxx.00.xx'; // < - 我应该在这里包含PORT吗?
serverName='xxx.xxx.00.xx'; //<-- should I include PORT here?


connectionInfo = array(
' 数据库' => ' DBName'
' UID' => ' userName'
< span class =code-string> PWD => ' 密码);

connectionInfo=array( 'Database'=>'DBName', 'UID'=>'userName', "PWD"=>'Password');


conn = sqlsrv_connect(
conn = sqlsrv_connect(


这篇关于如何将我托管的php网站连接到我本地服务器上的sql server数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆