Jump to content
Sign in to follow this  
kiberhack

mssql и php 5.3+

Recommended Posts

Добрый вечер вот решил сменить версию php на 5,3+ и вот что выдает:

Catchable fatal error: Argument 2 passed to sqlsrv_connect() must be an array, string given in C:\OpenServer\domains\test.ru\stats.php on line 6
<?php 
$host     = "localhost"; 
$username = "test"; 
$password = "test"; 

$connection=sqlsrv_connect($host,$username,$password) or die("Сервер временно недоступен"); 

function do_query($query,$database) 
    { 
        sqlsrv_select_db($database) or die("Сервер временно недоступен"); 
        return sqlsrv_query($query); 
    } 

     
$result=do_query("SELECT name FROM account_login","AccountServer"); 
$acc_num=sqlsrv_num_rows($result); 

$result=do_query("SELECT cha_id FROM character","GameDB"); 
$user_num=sqlsrv_num_rows($result); 

$result = do_query("SELECT * FROM guild WHERE member_total > 0 ORDER BY guild_name","GameDB"); 
$gui_num=sqlsrv_num_rows($result); 
?> 


<style type="text/css"> 
#name {color: #EAEAEA;left: relative;top: 1px;font-size: 13px;} 
</style> 

<table background="stat-bg.png"> 
 <script>
<!--
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2) {
(message);
return false;}}}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS;
}else{
document.onmouseup=clickNS;
document.oncontextmenu=clickIE;
}
document.oncontextmenu=new Function("return false")
-->
</script>
<tr><td colspan="3"></td></tr>
<tr></td><td id="name" ><b>Аккаунтов:</td></b><b><td id="name" ><?=$acc_num;?></b></td></tr>
<tr></td><td id="name" ><b>Персонажей:</td></b><b><td id="name" ><?=$user_num;?></b></td></tr> 
<tr></td><td id="name" ><b>Гильдий:</td></b><b><td id="name" ><?=$gui_num;?></b></td></tr>
<tr><td colspan="3"></td></tr> 
</table>

php.ini  показывает что все норм как на скрине, помогите решить проблему заранее благодарен.

Безымянный1.png

Безымянный2.png

Share this post


Link to post
Share on other sites

Привет @kiberhack!

 

Почитай документацию на функцию sqlsrv_connect(), там же есть примеры.

 

Данная функция принимает 2 параметра. В первом параметре указывается адрес MSSQL-сервера. Вторым параметром передается массив (array) с настройками подключения (база данных, логин, пароль).

 

В твоем случае код будет выглядеть примерно так:

$connectionInfo = array("Database" => "GameDB", "UID" => "test", "PWD" => "test");
$connection = sqlsrv_connect("localhost", $connectionInfo);

 


Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...