Fatal error: Call to undefined function: mssql_connect() in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Fatal error: Call to undefined function: mssql_connect() in

Post by shiranwas »

Hi,,

Fatal error: Call to undefined function: mssql_connect() in c:\apache\htdocs\complaints\Conn.php on line 5



when i trying to commect to MSSQL2000 I get aboue error message,
what is the error with my code,

Code: Select all

<?php

		$username = "sa";
		$password = "admin";
		$server= "SOFT_7";	
		$dbh =mssql_connect($server, $username, $password) 		
		or die("Unable to connect to mssql");		
		mssql_select_db('ecomplains',$dbh);
?>

thanx in advance
shiran
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Try this one

Code: Select all

<?php
echo 'mysql extension loaded: ', extension_loaded('mssql') ? 'yes':'no';
?>
if it says 'no' read http://de2.php.net/mssql esp. "Requirements" and "Installation"
User avatar
shiranwas
Forum Commoner
Posts: 53
Joined: Fri Jul 07, 2006 10:41 pm
Location: Colombo

Post by shiranwas »

hi,

i tried

Code: Select all

<?php 
echo 'mysql extension loaded: ', extension_loaded('mssql') ? 'yes':'no'; 
?>
echo 'mysql extension loaded: no

i do not understand what was there in the link u given to me

Installation
The MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini.

To get these functions to work, you have to compile PHP with --with-mssql[=DIR], where DIR is the FreeTDS install prefix. And FreeTDS should be compiled using --enable-msdblib.



shiran
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I suppose you use php on some windows system.
Did you download a php package that has a php_mssql.dll in either the directory extension(php4) or in ext(php5)?
If so, run

Code: Select all

<?php phpinfo(); ?>
to find out which php.ini is used. In this file there is probably a line
;extension=php_mssql.dll
Remove the semicolon, save the file and restart the apache.
If you met Requirements for Win32 platforms the mssql extension schould now be available.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

Also, are you sure you are installing Microsoft SQL Server (MSSQL)? Or are you installing MySQL ?? The 2 are completely different.

Second, what version of php are you using? Are you using 4.x or 5.x? If you are using 5.x, you should be using mysqli, not mysql.

Last, as the others have said, you may want to ensure you installed the libraries and extensions, and also that you setup the php.ini correctly.
Post Reply