php串連sql失敗

來源:互聯網
上載者:User
代碼:$dbc = mysqli_connect('localhost','tom', '123123', 'aliendatabase')
or die('Error connecting to MySQL server.');
也分離了資料庫一個mdf和一個ldf檔案放在同一個檔案夾中。
但是測試時還是出錯,好像是無法串連SQL伺服器位置:
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2003): Can't connect to MySQL server on 'localhost' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22
Error connecting to MySQL server.
我用的是Microsoft SQL Server 2005,我的SQL是串連伺服器的了,使用者名稱和密碼也沒有錯。求解。


回複討論(解決方案)

你用的是微軟Microsoft SQL卻用mysqli去串連能串連上就見鬼了
mssql_connect

小弟剛學php,很多都不懂的。麻煩大神再幫我看看,我改了之後還是錯。
$dbc = mysql_connect('localhost','tom', '123123', 'aliendatabase')
or die('Error connecting to MySQL server.');
$query = "INSERT INTO aliens_abduction (first_name, last_name, when_it_happened, how_long, " .
"how_many, alien_description, what_they_did, fang_spotted, other, email) " .
"VALUES ('$first_name', '$last_name', '$when_it_happened', '$how_long', '$how_many', " .
"'$alien_description', '$what_they_did', '$fang_spotted', '$other', '$email')";
$result = mysql_query($dbc, $query)
or die('Error querying database.');
mysql_close($dbc);

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'localhost' (10061) in E:\Learing\phpWeb\aliens\report.php on line 22
Error connecting to MySQL server.

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.