Results 1 to 7 of 7

Thread: call to undefined function mssql_connect()

  1. #1
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

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

  2. #2
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Do you have the PECL odbtp >= 1.1.1 package installed?
    http://pecl.php.net/package/odbtp
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. #3
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by fileserverdirect View Post
    Do you have the PECL odbtp >= 1.1.1 package installed?
    http://pecl.php.net/package/odbtp
    none..

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Then the functions are not installed on your server. If you have access to install them, then you can do that. If not, you cannot use these functions.

    If you do have permission to modify the PHP configuration, start here: http://www.php.net/manual/en/mssql.setup.php
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Then the functions are not installed on your server. If you have access to install them, then you can do that. If not, you cannot use these functions.

    If you do have permission to modify the PHP configuration, start here: http://www.php.net/manual/en/mssql.setup.php
    i will try install later...thank you

  6. #6
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    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:

    Server Type: Database Engine
    Server name: ComputerName\SQLEXPRESS
    Authentication: Windows Authentication
    Username: NETBIOS NAME\Administrator [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\Administrator Password: [no password]

    this is my php 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"); 
    //} 


    $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_sqlsrv_52_ts_vc6.dll
    extension=php_bz2.dll
    extension=php_curl.dll
    extension=php_dba.dll
    extension=php_exif.dll
    extension=php_gd2.dll
    extension=php_gettext.dll

    mssql.allow_persistent=On
    mssql.max_persistent=-1
    mssql_max_links=-1
    mssql.min_error_severity=10
    mssql.compatibility_mode=Off
    mssql.connect_timeout=5
    mssql.timeout=60
    mssql.textlimit=4096
    mssql.textsize=4096
    mssql.batchsize=0
    mssql.datetimeconvert=On
    mssql.secure_connetion=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\system32. 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\wwwroot\web_intranet\index.php on line 17

    I hope somebody can help or tell me what I should do.
    Thank you

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    It's just not part of your system. Have you tried to install it? This is something different than a configuration.

    Start here:
    http://www.php.net/manual/en/mssql.setup.php


    I don't know the answer to your problem: I have had similar problems and found the answers on php.net.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •