Forum Moderators: coopster

Message Too Old, No Replies

MS-SQL Server 2000

php script on linux to access SQL server 2000

         

mjar81

6:25 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



so. i have a huge database that is mantained and updated on a daily basis. It is on a MS-SQL 2000 server. I need that data to be exported, preferably by a php script using a cron job every morning, to a MySQL database if anything has changed.

I can write the code to do the SQL stuff and maipulate the data, but i'm confused as hell as how to connect to a MS-SQL server using either windows or linux (preferably linux) in order to GET the data!

Any help would be appreciated... php's documentation of MS-SQL functions is very "lacking".

thanks,
mjar81

Zipper

6:52 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



no big difference from mysql, unless you want to use a DB module. but if you need to run it on linux u need to get the FreeTDS [freetds.org] library.

$db_conn = mssql_connect("sqlserver" , "sqluser" , "sqlpassword" );
mssql_select_db("sqldb", $db_conn);
$result = mssql_query('SELECT * FROM table', $db_conn );
while ($row = mssql_fetch_array($result)) {
//continue as usual
}

[edited by: jatar_k at 8:17 pm (utc) on Feb. 1, 2005]
[edit reason] removed url [/edit]

mjar81

7:09 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



hmm...
[codes]
fatal error: Call to undefined function mssql_connect() in d:\webroot\catalog\test.php on line 2
[/codes]

seems like i don't have the dll extensions enabled on my windows testing box...

and i get the error:
"Warning: PHP Startup: Unable to load dynamic library 'c:\php\php_mssql.dll' - the specified module could not be found"

i looked in the c:\php directory and the file is there!

thanks for your help,
mjar81

Zipper

7:30 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



did you add extension=php_mssql.dll under Dynamic/Windows Extensions in php.ini

mjar81

7:56 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



yeas. i uncommented it in my php.ini and restarted my webserver and it gave me that message (previous post) in a little popup window.

Zipper

8:04 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



found this

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from \winnt\system32 on the server to \winnt\system32 on the PHP box. Copying ntwdblib.dll will only provide access. Configuration of the client will require installation of all the tools.

mjar81

8:09 pm on Jan 31, 2005 (gmt 0)

10+ Year Member



yeah, i just stumbled across something like this as well... i don't have access to that software and don't know where to get it so i guess i'm screwed till i get my new linuz server in a few days...

CRAP!

thanks for helping though,
Mjar81

bcolflesh

8:18 pm on Jan 31, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try the latest note here:

[us2.php.net...]