mssql connection Call to undefined mssql_connect()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • newphpcoder

    mssql connection Call to undefined mssql_connect()

    Actually, now I only test my webpage in a computer that I create as a server. And also I’m not too familiar in a server. Now I created a database in SQL Server 2005 Express and some of information I will share is:

    I also used:
    SQL Server 2005 Express
    IIS 6.0
    php 5.2.14

    Server Type: Database Engine
    Server name: ComputerName\SQ LEXPRESS
    Authentication: Windows Authentication
    Username: NETBIOS NAME\Administra tor [hide]
    Password: [hide]

    My problem is I cannot connect to my database using php and I don't know what username and password I should use if the Username: NETBIOS NAME\Administra tor Password: [no password]

    This is my php code:

    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"); 
    //} 
    
    
    $server = "Computer Name\SQLEXPRESS";
    $user = "NETBIOS\Administrator";
    $pass = "";
    $db_name="dbase"; 
    
    //connection to database
    $dbhandle = mssql_connect($server, $user, $pass) or die ("Cannot connect to Server");
    
    //mssql_connect($server, 'sa', 'pass') or die("Cannot connect to server"); 
    $selected = mssql_select_db($db_name, $dbhandle)or die("Cannot select DB");    
    
    
            $department = $_POST['department'];    
            $username = $_POST['username']; 
    
            $sql=mssql_query("SELECT `Department`, `Username` FROM `tbl_user` 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 don't know if what configuration i need to do to work my connection. I configured php.ini like:

    I uncommented the following:

    extension_dir = "C:\php\ext "
    extension=php_s qlsrv_52_ts_vc6 .dll
    extension=php_b z2.dll
    extension=php_c url.dll
    extension=php_d ba.dll
    extension=php_e xif.dll
    extension=php_g d2.dll
    extension=php_g ettext.dll

    mssql.allow_per sistent=On
    mssql.max_persi stent=-1
    mssql_max_links =-1
    mssql.min_error _severity=10
    mssql.compatibi lity_mode=Off
    mssql.connect_t imeout=5
    mssql.timeout=6 0
    mssql.textlimit =4096
    mssql.textsize= 4096
    mssql.batchsize =0
    mssql.datetimec onvert=On
    mssql.secure_co nnetion=Off

    FreeTDS default to 4096
    mssql.max_procs =25
    mssql.charset = "ISO-8859-1"

    After I commented out that in php.ini, I put all sqlsrv file in C:\php\ext and the ntwdlib.dll into C:\WINDOWS\syst em32. After that still when I run my webpage the error is still there. I have no idea how I can fix that error.


    Error:
    Fatal error: call to undefined function mssql_connect() in C:\Inetpub\wwwr oot\web_intrane t\index.php on line 17

    I hope somebody can help or tell me what I should do.
    Thank you
    Last edited by Niheel; Sep 30 '10, 01:45 AM.
  • ck9663
    Recognized Expert Specialist
    • Jun 2007
    • 2878

    #2
    This is more of a PHP question first, than an MSSQL question. Search how you connect PHP to databases (oracle, sybase, access, mssql, etc). Then we go from there...

    Try posting this in PHP forum, they might be able to help you more...

    Good Luck!!!

    ~~ CK

    Comment

    Working...