前提・実現したいこと
CentOS(7.5.1804)にPHP(ver 7.0.31)をインストールし、word pressをその上で動かしています。
そのword pressからAzure上のSQL Serverへ接続するため、PHPのプログラムを記述し、ショートコードにてWord Pressに読み込ませようとしています。
発生している問題・エラーメッセージ
上記
A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.```
該当のソースコード
php
1$ServerName = "xxx.xxx.xxx.xxx,619xx"; 2 3// コネクションの設定 4$ConnectionInfo = array( 5"UID"=>"xxxxxxxxxxxxx", 6"PWD"=>'xxxxxxxxx', 7"Database"=>"xxx", 8"CharacterSet"=>"UTF-8"); 9 10 $dbCon = sqlsrv_connect($ServerName , $ConnectionInfo); 11 if($dbCon) 12 { 13 sqlsrv_close($dbCon); 14 return "database connection is active."; 15 } 16 else { 17 return print_r(sqlsrv_errors(),true); 18 }
試したこと
該当のサーバにてsqlcmdコマンドを用い、上記のパラメタを入力して実行したところ、問題なく接続することができました(実際にSELECT文なども実行できました)。また、多少強引ですが、telnet xxx.xxx.xxx.xxx 619xxとしたところ、接続できました。
補足情報(FW/ツールのバージョンなど)
・以前は接続できていたような気がしますが、少し前に本サーバを再起動した後うまくいかなくなったようです。
・sqlcmdで接続できているため、何らかが悪いのだと思いますが、皆目見当がつきません・・・
・Word Pressにて動作させていると書きましたが、Word Pressは関係なさそうで、本PHPを単体で試してもうまく行きませんでした。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。