command line: undefined function: mssql_connect()

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Thresher
Forum Newbie
Posts: 13
Joined: Sun Apr 01, 2007 3:12 am

command line: undefined function: mssql_connect()

Post by Thresher »

I have a PHP program that calls mssql_connect(). When I execute this program in a web browser, it succeeds. When I execute this program from the command line (with the -q flag), I get:

Fatal error: Call to undefined function: mssql_connect() in C:\test.php on line 16

Even if I call dl("php_mssql.dll") in the command line program I get the same error.

Any suggestions? Thanks.

My configurations:

PHP 4.4.2
Apache HTTP Server 2.0.58
Windows Server 2000

In php.ini I have uncommented:
extension=php_mssql.dll

When I call get_loaded_extensions() in a browser:

Array (
[0] => standard
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => com
[5] => ftp
[6] => mysql
[7] => odbc
[8] => overload
[9] => pcre
[10] => session
[11] => tokenizer
[12] => xml
[13] => wddx
[14] => zlib
[15] => apache2handler
[16] => mssql
)

When I call get_loaded_extensions() from the command line:

Array (
[0] => standard
[1] => bcmath
[2] => calendar
[3] => ctype
[4] => com
[5] => ftp
[6] => mysql
[7] => odbc
[8] => overload
[9] => pcre
[10] => session
[11] => tokenizer
[12] => xml
[13] => wddx
[14] => zlib
)

Notice the missing [16] => mssql.
User avatar
Darhazer
DevNet Resident
Posts: 1011
Joined: Thu May 14, 2009 3:00 pm
Location: HellCity, Bulgaria

Re: command line: undefined function: mssql_connect()

Post by Darhazer »

Probably the CLI php.ini is different by the one used by the apache.
You can determine the location of php.ini by running
php -r "phpinfo();" | grep php.ini
Sorry, this is in Unix... I don't know how to perform the same in Windows, but... maybe output php.info() to file and then chech the path to php.ini file?
php -r "phpinfo();" > phpinfo.txt
Thresher
Forum Newbie
Posts: 13
Joined: Sun Apr 01, 2007 3:12 am

Re: command line: undefined function: mssql_connect()

Post by Thresher »

Thanks for the reply Darhazer. But I have only one php.ini on the machine located in C:\WINTT. Further, the following outputs show that "php for httpd" and "php cli" use the same php.ini:

\php\php.exe -i
<tr><td class="e">Configuration File (php.ini) Path </td><td class="v">C:\WINNT </td></tr>

\php\cli\php.exe -i
Configuration File (php.ini) Path => C:\WINNT


Here are the parts of php.ini that involve mssql:

Code: Select all

 

Code: Select all

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;
;Windows Extensions
extension=php_mssql.dll
 
[MSSQL]
; Allow or prevent persistent links.
mssql.allow_persistent = On
 
; Maximum number of persistent links.  -1 means no limit.
mssql.max_persistent = -1
 
; Maximum number of links (persistent+non persistent).  -1 means no limit.
mssql.max_links = -1
 
; Minimum error severity to display.
mssql.min_error_severity = 10
 
; Minimum message severity to display.
mssql.min_message_severity = 10
 
; Compatability mode with old versions of PHP 3.0.
mssql.compatability_mode = Off
 
; Connect timeout
;mssql.connect_timeout = 5
 
; Query timeout
;mssql.timeout = 60
 
; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textlimit = 4096
 
; Valid range 0 - 2147483647.  Default = 4096.
;mssql.textsize = 4096
 
; Limits the number of records in each batch.  0 = all records in one batch.
;mssql.batchsize = 0
 
; Specify how datetime and datetim4 columns are returned
; On => Returns data converted to SQL server settings
; Off => Returns values as YYYY-MM-DD hh:mm:ss
;mssql.datetimeconvert = On
 
; Use NT authentication when connecting to the server
mssql.secure_connection = Off
 
; Specify max number of processes. -1 = library default
; msdlib defaults to 25
; FreeTDS defaults to 4096
;mssql.max_procs = -1
 
Last edited by Benjamin on Mon May 18, 2009 10:25 am, edited 1 time in total.
Reason: Added [code] tags.
Post Reply