Fatal error: Call to undefined function mssql_connect()
#1
Posted 13 May 2008 - 11:28 PM
I'm running Windows Server 2003, MS Sql 2005, and IIS6. I am trying to connect php to my sql database, and I keep getting the following error from the script below:
Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\testphpsql.php on line 4
<html>
<body>
<?php
$con = mssql_connect ("servername", "user", "password");
mssql_select_db ("ad-ls_phpbb", $con);
$sql= "SELECT * FROM TestTable";
$rs= mssql_query ($sql, $con);
echo "The field number one is: ";
echo mssql_result ($rs, 0, 0);
mssql_close ($con);
?>
</body>
</html>
I'm new to PHP in general, but I have copied all of my .dlls from my php folder into my system32 folder, and I have uncommented extension=php_mssql.dll in my php.ini file.
I'm lost, I've looked though the boards and used search but nobody ever seems to come back and say what fixed this issue. I'll be greatful for any help.
Thanks,
Chris
#2
Posted 14 May 2008 - 03:12 AM
<?
$rs= mssql_query ($sql, $con);
//to become
$rs= mssql_query ($sql);
or connect as follows:
//db connection
$con = mssql_connect ($dbHost, $dbUser, $dbPass) or die ('MsSQL connect failed. ' . mssql_error());
mssql_select_db($dbName) or die('Cannot select database. ' . mssql_error());
$dbHost = 'localhost';
$dbUser = 'root';
$dbPass = '';
$dbName = '';
//define your parameters accordingly
?>
#3
Posted 14 May 2008 - 07:35 AM
The php.ini that you are changing must be the one that php is using.
The php_mssql.dll must be in the ext folder.
The extension_dir setting in php.ini must be set to the ext folder, something like extension_dir = c:\php\ext
To get changes made to php.ini to take effect, you must stop and start the IIS web service. Do this in the services control panel or reboot your computer. Just stopping and starting the web site in the IIS management console is not enough.
mssql requires: ntwdblib.dll to be available on the Windows PATH. It is better to add the php folder to the Windows PATH instead of moving any files around. Re-logon or reboot your computer to get any changes made to the Windows PATH statement to take effect.
The php folder must have proper permissions set to allow the IIS user account to read the files in the php folder and in the ext folder.
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.
Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.
#4
Posted 14 May 2008 - 09:06 AM
#5
Posted 15 May 2008 - 10:31 PM
PFMaBiSmAd, I have made sure that each file that comes up in *php*.ini and looks like like a php.ini file has php_mssql.dll uncommented.
php_mssql.dll is in the folder that is specified by extension_dr in each .ini
I have stopped and restarted IIS several times, used iisreset/stop and /start and have rebooted the computer.
mtwdblib.dll is in system32, AND the php dir is in the PATH variable.
I reset permissions on the php folder to full control for everyone. Might not be the smartest thing, but I wanted to make sure it wasn't a permissions error since my server is not yet live.
Gnawz,
<html>
<body>
<?
$rs= mssql_query ($sql);
//or connect as follows:
//db connection
$con = mssql_connect ($dbHost, $dbUser, $dbPass) or die ('MsSQL connect failed. ' . mssql_error());
mssql_select_db($dbName) or die('Cannot select database. ' . mssql_error());
$dbHost = 'localhost';
$dbUser = '######';
$dbPass = '######';
$dbName = '######';
//define your parameters accordingly
?>
</body>
</html>
Still gives me:
Fatal error: Call to undefined function mssql_query() in C:\Inetpub\wwwroot\testphpsql.php on line 4
I of course did define username, password, and db
Thank you
#6
Posted 15 May 2008 - 10:39 PM
The php.ini that you are changing must be the one that php is using.
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.
Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.
#7
Posted 16 May 2008 - 09:52 AM
I made sure all four had php_mssql.dll without the leading ';'.
I made sure all four pointed to the folder with php_mssql.dll in the extension_dir variable.
Like I stated earlier, I'm a complete newb at this. I have 0 experence with php but was forced to take on a project that needs it.
Thanks for your help.
#8
Posted 16 May 2008 - 10:28 AM
Check wildteen88's instructions in that thread to use a phpinfo(); statement to see what if any php.ini is getting loaded.
Debugging step #1: To get past the garbage-out equals garbage-in stage in your code, you must check that the inputs to your code are what you expect.
Programming is just problem solving, but it is done in another language. You must learn enough of the programming language you are using to be able to read and write code.
#9
Posted 16 May 2008 - 10:18 PM
Here is my path var.
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\XAMPP\php\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\
Why won't it look to my php folder? Looking in my C:\windows folder, there is no php.ini there. How is even phpinfo even working if it is looking for a place where the ini doesn't live?
#10
Posted 17 May 2008 - 10:48 AM
System Windows NT 5.2 build 3790
Build Date Nov 8 2007 23:18:08
Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"
Server API ISAPI
Virtual Directory Support enabled
Configuration File (php.ini) Path C:\WINDOWS ???
Loaded Configuration File C:\XAMPP\php\php.ini ???
PHP API 20041225
PHP Extension 20060613
Zend Extension 220060519
Debug Build no
Thread Safety enabled
Zend Memory Manager enabled
IPv6 Support enabled
Registered PHP Streams php, file, data, http, ftp, compress.zlib, zip
Registered Stream Socket Transports tcp, udp
Registered Stream Filters convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*
#11
Posted 17 May 2008 - 11:37 AM
if (function_exists('mssql_fetch_row')) {
echo "MSSQL functions are available.<br />\n";
} else {
echo "MSSQL functions are not available.<br />\n";
}
?>
Returns: MSSQL functions are available
#12
Posted 17 August 2009 - 05:45 AM
I'm running Windows XP, MS Sql 2005, and APACHE2.0.x. I am trying to connect php to my sql database, and I keep getting the following error from the script below:
Fatal error: Call to undefined function mssql_connect() in Fatal error:
Call to undefined function mssql_connect()
MSSQL functions not available. What should i do , to available and execute it succesfully?
Thanks,
TripleM
#13
Posted 03 September 2009 - 12:27 PM
BTW, if you're seeing TWO copies of php.ini in the same folder, then something is dramatically wrong, because no OS that I know of will allow two files with the same filename to exist in the same folder. My guess is you have Windows "hiding known file extensions" and you're really looking at php.ini.txt and php.ini.???
When in Explorer. you should go to Tools > Folder Options > View... and UNCHECK "Hide extensions..."
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











