[英]Making sql server 2008 connection with PHP with sqlsrv big problems
I know there are some threads with this topic, but I'm a little desperate now so I think I should do a new one. 我知道有一些与此主题相关的主题,但是我现在有些绝望了,所以我认为我应该再做一个主题。 I´m trying to connect sql server 2008 with php, I'm using WAMP server and php 5.4.3. 我正在尝试使用php连接sql server 2008,我正在使用WAMP服务器和PHP 5.4.3。 I have read a lot about the configuration of the php.ini file and I did what I needed to do. 我已经阅读了很多有关php.ini文件的配置,并且做了我需要做的事情。 But still I can´t get my connection working! 但是我仍然无法连接! This is a little summary of what I´ve done 这是我所做的一些总结
with this information I found i need this new lines in my php.ini file 有了这些信息,我发现我需要在php.ini文件中换行
For SQLSRV30.EXE, PHP 5.4, TS, VC9 add lines: [PHP_SQLSRV] extension=php_sqlsrv_54_ts.dll [PHP_PDO_SQLSRV] extension=php_pdo_sqlsrv_54_ts.dll 对于SQLSRV30.EXE,PHP 5.4,TS,VC9,添加以下行:[PHP_SQLSRV]扩展名= php_sqlsrv_54_ts.dll [PHP_PDO_SQLSRV]扩展名= php_pdo_sqlsrv_54_ts.dll
Restart my server!! 重新启动我的服务器!
Ok so I have a page whit this code: 好的,所以我有一个页面上面的代码:
<html>
<head>
<title>Resultado</title>
</head>
<body>
<?php
$server='ANDRES-PC';
$connectinfo=array("Database"=>"ejemplo");
//connect to DB
$db=sqlsrv_connect($server,$connectinfo);
if($db)
{
echo "Connection established.<br/>";
}
else
{
echo "Connection couldn't be established.<br/>";
die(print_r( sqlsrv_errors(), true));
}
?>
</body>
</html>
But when I try to see the page I got nothing!!! 但是,当我尝试查看页面时,我什么也没有! Not a single word. 没有一个字。 What do you thing is my problem. 你怎么了是我的问题。 I used this page http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html to set up the connection!! 我使用此页面http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html来建立连接! please help 请帮忙
You've done everything correctly, so I'm guessing you have installed the 64 bit version of WAMP. 您已正确完成所有操作,所以我猜您已安装了64位版本的WAMP。 Please see this answer: 请查看以下答案:
http://social.msdn.microsoft.com/Forums/en-US/sqldriverforphp/thread/6dc1dc1a-5d74-415b-9225-ce11f481f301 http://social.msdn.microsoft.com/Forums/zh-CN/sqldriverforphp/thread/6dc1dc1a-5d74-415b-9225-ce11f481f301
Somewhere high up on my instructions page it says you must use 32 bit PHP: "Microsoft's PHP driver for SQL Server only runs with PHP 32-bit builds" 在我的说明页上的某个地方,它说您必须使用32位PHP:“ Microsoft SQL Server的PHP驱动程序只能与32位PHP版本一起运行”
Edit: never mind! 编辑:没关系! I noticed your recent comment on my blog page: http://robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html 我注意到您最近在我的博客页面上发表的评论: http : //robsphp.blogspot.co.uk/2012/09/how-to-install-microsofts-sql-server.html
I'll leave this answer as it's a common reason for the sqlsrv driver not loading with WAMP. 我将保留此答案,因为这是sqlsrv驱动程序未随WAMP一起加载的常见原因。
Sqlsrv driver works only with 32-bit version of wamp. Sqlsrv驱动程序仅适用于32位版本的wamp。 Install 32-bit version of wamp or connect to MSSQL using PDO connection with odbc driver new PDO("odbc:dsn"); 安装32位版本的wamp或使用odbc驱动程序new PDO(“ odbc:dsn”)的PDO连接连接到MSSQL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.