Good day! I change my database from sql yog to SQL Server 2005 Express so in php the connection is different, so now I am new in SQL Server 2005 Express. i edit my login page and I encountered error: Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\web_intranet\index.php on line 14 here is my code: <?php session_start(); session_regenerate_id(); if($_SESSION['loggedin']){ //the user is already logged in, lets redirect them to the other page header("Location:company.php"); } //require_once 'conn.php'; $server = "PDOMAIN\MSFW"; $db_name="dspi"; mssql_connect($server) or die("Cannot connect to server"); mssql_select_db("$db_name")or die("Cannot select DB"); $department = $_POST['department']; $username = $_POST['username']; $sql=mssql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mssql_min_error_severity()); $ct = mssql_num_rows($sql); if($ct == 1) { // im guessing this means that the user is valid. $_SESSION['loggedin'] = true; // now that the user is valid we change the session value. $row = mssql_fetch_assoc($sql); //$_SESSION['username'] = $row['Username'] ; //$_SESSION['department'] = $row['Department']; $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain'); if (in_array($row['Department'], $Departments)){ header ('Location:company.php'); }else{ echo "Incorrect Username or Department"; header ('Location:index.php'); } } ?> PHP: call to undefined function mssql_connect() -------------------------------------------------------------------------------- Good day! I change my database from sql yog to SQL Server 2005 Express so in php the connection is different, so now I am new in SQL Server 2005 Express. i edit my login page and I encountered error: Fatal error: Call to undefined function mssql_connect() in C:\Inetpub\wwwroot\web_intranet\index.php on line 14 here is my code: PHP Code: <?php session_start(); session_regenerate_id(); if($_SESSION['loggedin']){ //the user is already logged in, lets redirect them to the other page header("Location:company.php"); } //require_once 'conn.php'; $server = "PDOMAIN\MSFW"; $db_name="dspi"; mssql_connect($server) or die("Cannot connect to server"); mssql_select_db("$db_name")or die("Cannot select DB"); $department = $_POST['department']; $username = $_POST['username']; $sql=mssql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mssql_min_error_severity()); $ct = mssql_num_rows($sql); if($ct == 1) { // im guessing this means that the user is valid. $_SESSION['loggedin'] = true; // now that the user is valid we change the session value. $row = mssql_fetch_assoc($sql); //$_SESSION['username'] = $row['Username'] ; //$_SESSION['department'] = $row['Department']; $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain'); if (in_array($row['Department'], $Departments)){ header ('Location:company.php'); }else{ echo "Incorrect Username or Department"; header ('Location:index.php'); } } ?> i already enable extension mssql in php.ini
First you need to check if your MS SQL Server could be connected from other host. Usually i have to configure the MS SQL server so it can be connected from the client. Enable TCP/IP and bla bla... i forgot what i did. But please test your MS SQL can be connected from C# or ASP.NET. If connected then you should find what is your PHP version. Looks like PHP 5.2.0 have bugs to connect to MS SQL: http://bugs.php.net/bug.php?id=40034 Then the last thing, please check if MSSQL driver installed in your PHP. PHP connect to MS SQL server with ODBC, please check of ODBC driver is installed. See this for reference: http://www.easysoft.com/developer/languages/php/sql_server_unix_tutorial.html
By the way i use Windows Server 2003, IIS, php 4.3.4,and SQL Server 2005 Express i configure already the php.ini for mssql. I also check if i have the php_mssql.dll in my extension folder and i have it. What do you mean other host? After i configure my php.ini still i cannot connect to sql.
First check if you can access your SQL server from APS.net. Then in your PHP installation check if you have the : ntwdblib.dll and install the last MDAC (v2.8). For more details see: http://php.net/manual/en/function.mssql-connect.php and http://www.helpspot.com/helpdesk/index.php?pg=kb.page&id=13
Yes, enable odbc in php.ini and try connect with odbc_connect() See the manual here: http://php.net/manual/en/function.odbc-connect.php
Maybe this will help you also http://docs.moodle.org/en/Installin...SQL_Server_2005_Driver_for_PHP_from_Microsoft
Look at your phpinfo() function...if you don't have one, create it. <? phpinfo(); ?> save it as info.php or phpinfo.php, then call it from the browser. Near the top, you will see 2 lines in the table: Configuration File (php.ini) Path C:\WINDOWS Loaded Configuration File C:\PHP\php.ini If the Configuration File (php.ini) Path is C:\WINDOWS, simply copy ntwdblib.dll from c:\php to c:\windows. That should do it (as long as the Loaded Configuration File is the one that you removed the ";" from extension=php_mssql.dll Let me know if that doesn't help you.
He said that he did enable it, but a common problem I see is the configuration file path is set to C:\WINDOWS, which means that "ntwdblib.dll", which is requried for mssql.dll to work must be in that path. This is the same for mysql.dll and libmysql.dll. Hope this helps.