Jump to content


Photo

Fatal error: Call to undefined function mssql_query()

mssql php

  • Please log in to reply
4 replies to this topic

#1 maideen

maideen

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 02 March 2013 - 05:51 AM

Hi, I am new in PHP. I have tried to connect MSSQL 2005 through php.

I am using xampp 1.8.0 

But once run, error msg is "Fatal error: Call to undefined function mssql_query()".

I have copied  "php_mssql.dll" in PHP folder  and enable in PHP.ini as "extension=php_mssql.dll "

and also tried copied in PHP/ext folder also (all above got from forum PHP Freaks Previous topics)

 

But nothing happened. Same error appear. Can anybody help?

 

Pls Help me.

 

Below is code.  I am running xampp in my local mechine with Win 7 pro

 

It is config.php

 

 

<?php
$myServer = "sils-pc";
$myUser = "sa";
$myPass = "544Hjy%2*2";
$myDB = "tempDB"; 
    
$conn = new COM ("ADODB.Connection") or die("Cannot start ADO");
$connStr = "PROVIDER=SQLOLEDB;SERVER=".$myServer.";UID=".$myUser.";PWD=".$myPass.";DATABASE=".$myDB; 
$conn->open($connStr); 
?>

 

 

 

<?php
include 'config.php';
$query = "SELECT * FROM vw_Film_Certs_Display order by id";
//$query = mssql_query('SELECT * FROM [php].[dbo].[vw_Film_Certs_Display]');
$result = mssql_query($query);
$numRows = mssql_num_rows($result); 
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>"; 
while($row = mssql_fetch_array($result))
{
  echo "<li>" . $row["id"] . $row["name"] . $row["year"] . "</li>";
}
mssql_close($dbhandle);
?>

 

Please help me

 

 



#2 Round

Round

    Advanced Member

  • Members
  • PipPipPip
  • 99 posts
  • LocationEngland

Posted 09 April 2013 - 05:37 AM

Try this

 

$result = mssql_query($query, $conn); 

 

in the place of:

 

$result = mssql_query($query);

 

As you have to specify which connection to use. A page may have multiple db connections


Edited by Round, 09 April 2013 - 05:39 AM.

If it all gets too much just remember that, at the end of the day... It gets dark!! or that on the other hand... There are more Fingers!!
If you eventually get it right then Hip Hip ARRAY!! lol


#3 mac_gyver

mac_gyver

    Advanced Member

  • Administrators
  • 2,376 posts

Posted 09 April 2013 - 11:13 AM

putting the [optional] connection parameter into the query statement won't fix the fact that the extension isn't installed.

to the OP, if you should happen to visit this thread, starting in php5.3 the mssql extension is no longer available and you must switch your code to use the SQLSRV extension. wherever you found the php_mssql.dll file at, it is likely not complied for the same version of php you are using and isn't loading due to errors (check the web server error log.)

this regurgitated information can be found in the mssql documentation at php.net
multi-purpose programming fool and resident naysayer [We try not be negative in replies, but telling someone what they're doing wrong, while staying politically correct, isn't always going to happen.]

#4 Round

Round

    Advanced Member

  • Members
  • PipPipPip
  • 99 posts
  • LocationEngland

Posted 09 April 2013 - 12:39 PM

Never knew was optional as I've always included

If it all gets too much just remember that, at the end of the day... It gets dark!! or that on the other hand... There are more Fingers!!
If you eventually get it right then Hip Hip ARRAY!! lol


#5 DrTrans

DrTrans

    Advanced Member

  • Members
  • PipPipPip
  • 178 posts

Posted 10 April 2013 - 08:54 AM

You need to enable sql server support in the php.ini and install the sql server library.


Designing the web, www.OneDelve.com





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com