MSSQL_CONNECT in php (linux)

Status
Niet open voor verdere reacties.

buick

Terugkerende gebruiker
Lid geworden
6 sep 2001
Berichten
2.901
Besturingssysteem
Windows 10/11
Ik heb een php script gemaakt dat een verbinding moet openen naar een mssql 2000 server.

Maar als ik de pagina naar mijn provider(s) upload en start krijg ik de foutmelding :
Fatal error: Call to undefined function: mssql_connect()

Het lijkt erop dat deze instructie niet wordt herkend.

Ik heb meerdere hostingproviders geprobeert en bij allemaal kreeg ik dezelfrde fout.
Zij gebruiken php 4 en 5 op Linux / *nix systemen.


Is er een manier om de mssql_connect toch enabled te krijgen ? Volgens de PHP guide is het nl een geldige instructie voor php 3 tm 5.
 
btw hier de code. Ik denk niet dat er fouten inzitten want bij mensen die windows met php draaien schijnt hij wel te werken :confused:

Code:
<?php

	echo 'Current PHP version: ' . phpversion();
	//MSSQL Host IP
	$db_host = '**.**.**.**';
	
	//MSSQL Username
	$db_user = 'dbuser';
	
	//MSSQL Password
	$db_pass = 'mypassword';
	
	//MSSQL Database
	$db_name = 'test';
	
	$conn = mssql_connect($db_host,$db_user,$db_pass);
	mssql_select_db($db_name,$conn);
?>
 
Kep zelf geen ervaring met andere databasetypen dan MySQL, maar dit vond ik in de user notes van php.net, misschien dat je d'r wat aan hebt:
If you aren't "married" to a linux distribution yet, and want a quick turn-key solution for connecting to a mssql server from apache/php running on linux...here's what worked for me. Gentoo Linux has the freetds package (and sqsh, which is a cool tool) available as an emerge-able package (currently v0.61). Install the latest Gentoo distro (at this time is 1.4). Emerge freetds (and sqsh if you want it). No special make flags were needed. Download the latest tarballs of apache and php...follow the instructions for building statically. Make sure you include the "--with-mssql" statement in php ./configure options. With Gentoo, I didn't have to point the --with-mssql at a particular directory (I simply put "--with-mssql" and that's it) since freetds was installed via portage and was located automagically. Freetds looks for a freetds.conf file in several places..one of them being /etc, which was where portage installed it. My freetds.conf (minus comments and such) looks as follows:
[global]
tds version = 4.2
initial block size = 512
swap broken dates = no
swap broken money = no
try server login = yes
try domain login = no
cross domain login = no
text size = 64512
[MyServer70]
host = 192.168.0.25
port = 1433
tds version = 7.0

This may not be the most optimized config, but it worked. After everything is compiled and installed (with 4.3.4 I *did not* have to put in a line such as extension=mssql.so as earlier posts have mentioned in my php.ini file), start apache and try out your install with the following code snippet:
PHP:
<?
$msconnect=mssql_connect("MyServer70","sa","");
$msdb=mssql_select_db("Northwind",$msconnect);
$msquery = "select titleofcourtesy,firstname,lastname from employees";
$msresults= mssql_query($msquery);
while ($row = mssql_fetch_array($msresults)) {
       echo "<li>" . $row['titleofcourtesy'] . " " . $row['firstname'] . " " . $row['lastname'] .  "</li>\n";
}
?>
Note, as previously mentioned, the "server" portion of the mssql_connect() must match the string used in the freetds.conf file. My test mssql server was configured for "mixed mode authentication", "sa" for admin name, and blank password. Adjust your connection string for your environment.

It may be just as easy to get this running with RedHat or other distro...your mileage may vary. This, as I said, was what worked for me and it was very straightforward and worked without any special tricks. Sorry if this has some redundant info in it, but I hope this helps someone :) Cheers!

// p.s. Helpmij traag :8-0:
 
Waarschijnlijk zal ik dat dan door de hostingprovider moeten laten doen :( Ik heb zelf nl niet zoveel rechten, behalve dan het hosten van mijn site.

Zelf ben ik ook Mysql gewend en had dit ook vele malen liever gehad. Helaas draait de gameserver alleen onder windows2k en de bijbehorende database onder MSSql.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan