Error Connecting to SQL Server 2005 using PHP script – PHP

  php

Q(Question):

I am trying to connect to the SQL Server and then to create a database table using PHP script. The code is as follows,[php]<job id="sqlserver1">
<script language="PHPScript">
$connection = mssql_connect(‘UIE-LAPTOP-01\SQLEXPRESS’, ‘pugalenthi’ , ‘Qwert1!’);
mssql_select_db(‘tempdb’, $connection);
$sql = "CREATE TABLE Catalog(CatalogId VARCHAR(25), Journal
VARCHAR(25), Publisher Varchar(25), Edition VARCHAR(25), Title
Varchar(45), Author Varchar(25))";
mssql_query($sql);
</script>
</job>[/php]when i tried to run this script in a windows script host file, i got an error. The error was "call to undefined function mssql_connect(). Please help me.

A(Answer):

LAST WARNING:

As a full member you know by now that you have to enclose any code within the appropriate code tags!

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members’ questions.

Please use [code] tags in future.

MODERATOR

A(Answer):

Please suggest a solution to the above error.

A(Answer):

Please suggest a solution to the above error.

You will have to talk to your ISP, because this fatal error will be returned when the mssql extension is not installed or configured.

Ronald

A(Answer):

You will have to talk to your ISP, because this fatal error will be returned when the mssql extension is not installed or configured.

Ronald

It was me who had installed and configured the php. The SQL Server is also installed in the same computer. I am able to create an ODBC connection to sql server using php script.

A(Answer):

The ODBC extension of PHP is not the same as the mssql extension of PHP! That is a separate, independent, extension.

At my own (via ISP) webserver I also have mysql and ODBC, but not the mssql!

Run the phpinfo() function at your server and see if the return screen shows mssql.[php]<?php
phpinfo();
?>[/php]Ronald

A(Answer):

The ODBC extension of PHP is not the same as the mssql extension of PHP! That is a separate, independent, extension.

At my own (via ISP) webserver I also have mysql and ODBC, but not the mssql!

Run the phpinfo() function at your server and see if the return screen shows mssql.[php]<?php
phpinfo();
?>[/php]Ronald

I ran the phpinfo() function and i got long page listing all but the mssql extensions.

I have two .ini files in the path C:\PHP namely php-activescript.ini and php.ini. One was configured during active script installation. Should i remove that .ini file ?.

LEAVE A COMMENT