Page 1 of 1

problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 3:02 am
by ahad_yekta2004
I have a problem in connecting the wampp localhost to sql server , There is a lan network that it`s server is windows server 2008 with sql server 2008 , I want to connect to this sql by php in a client with windows 7 , but when I run mssql_connect function It shows that coudlent connect to this IP , It shows Reply when I ping server IP .
Do I have to change anything in wampp or php application in localhost ?
It is php 5.3 the latestversion of wampp .
Other programmers can connect to this sql by C sharp and Delphi , Only me cant access that by php
I use VmWare also , and install windows server 2008 and sql server 2008 , and create network between win7 and windows server by NAT , even in this way I cant access to sql by php , but there is reply in pinging servers IP .
,

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 3:36 am
by requinix
Use the sqlsrv extension, not the old and deprecated mssql extension.

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 4:33 am
by ahad_yekta2004
requinix wrote:Use the sqlsrv extension, not the old and deprecated mssql extension.
Doyou mean that?
http://www.microsoft.com/en-us/download ... x?id=20098

or somthing else?
if not could you please show me a link of that?

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 5:07 am
by requinix
Yes, that's it.

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 7:09 am
by ahad_yekta2004
requinix wrote:Yes, that's it.
I copy that files in php extension folder and add these lines in php.ini and restart services :

but it shows these errors :

Code: Select all

Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: message: The USE database statement failed because the database collation Persian_100_CI_AI is not recognized by older client drivers. Try upgrading the client operating system or applying a service update to the database client software, or use a different collation. See SQL Server Books Online for more information on changing collations. (severity 16) in C:\wamp\www\sql\index.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0
2	0.0003	672096	mssql_connect ( )	..\index.php:4

( ! ) Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: General SQL Server error: Check messages from the SQL Server (severity 16) in C:\wamp\www\sql\index.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0
2	0.0003	672096	mssql_connect ( )	..\index.php:4

( ! ) Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: message: Login failed for user 'sisi'. (severity 14) in C:\wamp\www\sql\index.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0
2	0.0003	672096	mssql_connect ( )	..\index.php:4

( ! ) Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: General SQL Server error: Check messages from the SQL Server (severity 14) in C:\wamp\www\sql\index.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0
2	0.0003	672096	mssql_connect ( )	..\index.php:4

( ! ) Warning: mssql_connect() [<a href='function.mssql-connect'>function.mssql-connect</a>]: Unable to connect to server: 192.168.170.139 in C:\wamp\www\sql\index.php on line 4
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0
2	0.0003	672096	mssql_connect ( )	..\index.php:4
Could not connect
( ! ) Fatal error: Call to undefined function mssql_error() in C:\wamp\www\sql\index.php on line 7
Call Stack
#	Time	Memory	Function	Location
1	0.0002	671808	{main}( )	..\index.php:0

What should I do . I`m not expert in sql server

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 8:09 am
by requinix
You're still using the mssql extension. I can tell because all the functions are called mssql_*. If you were using the sqlsrv extension then you would be using functions called sqlsrv_*. See the pattern?

Read the documentation: it's not like the extension is very different from mssql or even mysql(i).

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 9:38 am
by ahad_yekta2004
I use sqlsrv_connect but shows me an error that :
Fatal error: Call to undefined function sqlsrv_connect() in C:\wamp\www\sql\index.php on line 27

in php.ini I added thease lines:

extension=php_sqlsrv_53_ts.dll
extension=php_pdo_sqlsrv_53_ts.dll
extension=php_pdo.dll


I dont know wamp is threaded php or not threaded , It said that for not threaded use these lines .

When I was searching for sqlsrv I found out that it doesnt work for windows 7 64 bit , Do you test it in windows 64bit ?

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sun Sep 23, 2012 8:34 pm
by requinix
If the function is undefined then the extension isn't installed. Did you restart WAMP?

Regarding thread-safe versus non-thread-safe it actually depends on your Apache installation. IIRC on Windows you should probably use the thread-safe versions, but if that doesn't work then use the other.

I don't see anything that says you can't use it on Win7 x64 - only something which tells you which drivers will be installed (you get an x86 and an x64 rather than two x64s).

Re: problem-in-connecting-to-sql-server-2008-by-php

Posted: Sat Jan 26, 2013 1:41 am
by perhanna
Just what i have been looking for! Thank you very much vistad.