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'); } } ?>

By the way i use Windows Server 2003, IIS, php 4.3.4, and SQL Server 2005 Express
I already configure the php.ini to read mssql.
I also check if I have ntwdblib.dll and i have it.
but still i cannot connect to sql.

    PHP 4? PHP 4's lifetime ended a year ago. PHP 5 has been out for several years. I recommend you update to PHP 5.3.currentBuild yesterday or some time before that if possible.
    Other than that, the documentation at php.net should explain it.

      johanafm;10964075 wrote:

      PHP 4? PHP 4's lifetime ended a year ago. PHP 5 has been out for several years. I recommend you update to PHP 5.3.currentBuild yesterday or some time before that if possible.
      Other than that, the documentation at php.net should explain it.

      Why should i update my php version?

        newphpcoder wrote:

        Why should i update my php version?

        Plenty of reasons. Some examples I can think of off the top of my head:

        1. Security

        2. Performance

        3. Bug fixes

        4. Reliability

        5. Usability (a lot of applications/libraries/whatever require PHP5 nowadays; think GoPHP5)

        6. Support

          Another reason to move to PHP 5 is that you can use the SQL Server Driver for PHP (since you are running on Windows). The sqlsrv driver is built and supported by Microsoft. The mssql driver is based (as you know) on ntwdblib, which has been depricated. If you are interested in a more detailed look at the sqlsrv and mssql driver, check out this blog post: http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx. You can download the most recent version of the driver here: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=80e44913-24b4-4113-8807-caae6cf2ca05

          Hope that helps.

          -Brian

            Write a Reply...