7 Replies - 7435 Views - Last Post: 21 September 2010 - 08:33 PM Rate Topic: -----

#1 Guest_newphpcoder*


Reputation:

call to undefined function mssql_connect()

Posted 21 September 2010 - 01:10 AM

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.

Is This A Good Question/Topic? 0

Replies To: call to undefined function mssql_connect()

#2 Dormilich   User is offline

  • 痛覚残留
  • member icon

Reputation: 4219
  • View blog
  • Posts: 13,353
  • Joined: 08-June 10

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 01:14 AM

check in phpinfo() if mssql is active, otherwise restart your server.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 04:20 AM

Hi Rhoda Rose...why are you crossposting and using a guest account now?
Was This Post Helpful? 1
  • +
  • -

#4 Guest_Guest*


Reputation:

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 07:03 PM

View PostDormilich, on 21 September 2010 - 12:14 AM, said:

check in phpinfo() if mssql is active, otherwise restart your server.

i try to run phpinfo() and the page cannot be displayed
Was This Post Helpful? 0

#5 creativecoding   User is offline

  • Hash != Encryption
  • member icon


Reputation: 931
  • View blog
  • Posts: 3,216
  • Joined: 19-January 10

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 07:17 PM

View PostJackOfAllTrades, on 21 September 2010 - 03:20 AM, said:



pwned.



Are you sure you have mysql installed?
Was This Post Helpful? 0
  • +
  • -

#6 Valek   User is offline

  • The Real Skynet
  • member icon

Reputation: 544
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 08:02 PM

View Postcreativecoding, on 21 September 2010 - 10:17 PM, said:

View PostJackOfAllTrades, on 21 September 2010 - 03:20 AM, said:



pwned.



Are you sure you have mysql installed?


OP isn't using MySQL, she is using MSSQL.

Also, that's already been covered by Dormilich.
Was This Post Helpful? 0
  • +
  • -

#7 creativecoding   User is offline

  • Hash != Encryption
  • member icon


Reputation: 931
  • View blog
  • Posts: 3,216
  • Joined: 19-January 10

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 08:19 PM

View PostValek, on 21 September 2010 - 07:02 PM, said:

View Postcreativecoding, on 21 September 2010 - 10:17 PM, said:

View PostJackOfAllTrades, on 21 September 2010 - 03:20 AM, said:



pwned.



Are you sure you have mysql installed?


OP isn't using MySQL, she is using MSSQL.

Also, that's already been covered by Dormilich.



oops, sorry...


Carry on.
Was This Post Helpful? 0
  • +
  • -

#8 Atli   User is offline

  • Enhance Your Calm
  • member icon

Reputation: 4240
  • View blog
  • Posts: 7,216
  • Joined: 08-June 10

Re: call to undefined function mssql_connect()

Posted 21 September 2010 - 08:33 PM

View PostGuest, on 22 September 2010 - 01:03 AM, said:

View PostDormilich, on 21 September 2010 - 12:14 AM, said:

check in phpinfo() if mssql is active, otherwise restart your server.

i try to run phpinfo() and the page cannot be displayed

Is your server started? Did you use the correct URL? What did you do exactly?

We aren't psychic (... much) :)

One question, are you sure you are supposed to be using the mssql_* functions? Microsoft release their own PHP driver for SQL Server 2005, which uses sqlsrv_* functions. See sqlsrv_connect @ msdn.com. You could try that out.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1