473,418 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

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\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:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //session_start(); 
  3. //session_regenerate_id(); 
  4.  
  5. //if($_SESSION['loggedin']){ 
  6. //the user is already logged in, lets redirect them to the other page 
  7.   //  header("Location:company.php"); 
  8. //} 
  9.  
  10.  
  11. $server = "Computer Name\SQLEXPRESS";
  12. $user = "NETBIOS\Administrator";
  13. $pass = "";
  14. $db_name="dbase"; 
  15.  
  16. //connection to database
  17. $dbhandle = mssql_connect($server, $user, $pass) or die ("Cannot connect to Server");
  18.  
  19. //mssql_connect($server, 'sa', 'pass') or die("Cannot connect to server"); 
  20. $selected = mssql_select_db($db_name, $dbhandle)or die("Cannot select DB");    
  21.  
  22.  
  23.         $department = $_POST['department'];    
  24.         $username = $_POST['username']; 
  25.  
  26.         $sql=mssql_query("SELECT `Department`, `Username` FROM `tbl_user` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mssql_min_error_severity()); 
  27.         $ct = mssql_num_rows($sql); 
  28.  
  29.         if($ct == 1) { 
  30. // im guessing this means that the user is valid. 
  31. $_SESSION['loggedin'] = true; // now that the user is valid we change the session value. 
  32.             $row = mssql_fetch_assoc($sql);   
  33.  
  34.             //$_SESSION['username'] = $row['Username'] ;
  35.             //$_SESSION['department'] = $row['Department'];
  36.  
  37.             $Departments=array('Accounting', 'Engineering', 'Finishing_Goods', 'HRAD', 'MIS', 'Packaging_and_Design', 'Production', 'Purchasing_Logistic', 'QA_and_Technical', 'Supply_Chain');
  38.  
  39.             if (in_array($row['Department'], $Departments)){
  40.                     header ('Location:company.php');
  41.             }else{
  42.                     echo "Incorrect Username or Department";
  43.                     header ('Location:index.php');
  44.             }
  45.         }
  46. ?> 


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
Sep 30 '10 #1
1 1908
ck9663
2,878 Expert 2GB
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
Oct 1 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Antonis Konstantinos | last post by:
Hi all, My Linux (k2.4.13) machine is now working with PHP 4.3.3 with Apache 1.3.28 and Mysql 4.0.15a.. I am now writing a script that connects to a MSSQL v8.0 server. In order to do this I...
7
by: mj | last post by:
Hello, thanks for the help. I am running a WinXP Pro w/ SP2 (my home computer, with ZoneAlarm firewall) Apache 2.0.52 MySQL 4.1.7 PHP 5.1.0-dev I have developed a PHP/MySQL web app that...
2
by: Maniek | last post by:
Hi, Has anyone Pg linked to MSSQL or vice versa? I need to transfer some data MSSQL->PGSQL, but without writing a complex program. Maybe using Linked Server (MSSQL), ODBC / JDBC / OLE DB,...
0
by: dan | last post by:
Hi, I connect to a microsoft SQL server from php. Php is running on linux (debian sarge) with the freetds package. The connection is secured through stunnel (version 3.26), with stunnel running...
3
by: gharmel | last post by:
I'm trying to get some clues on why I get (much) slower responses from my PHP applications when dealing with a remote sql server as opposed to a local sql server. Here's my situation: Server...
2
by: grandmasterneil | last post by:
I have a couple of servers here at work that run IIS, MSSQL, and ASP.NET. I have PHP installed and running via Apache on my laptop. I was wondering if I can run code on my laptop (PHP/Apache)...
7
by: RossM | last post by:
Hey, I am trying to connect to a MSSQL database but i keep getting the error "Compile error: User-defined type not defined". My code is below: Option Explicit Private Sub...
0
by: menmaatre | last post by:
Hi all, I have a very odd problem: - System A: Win 2k3 with IIS 6 exposing a little WSDL Webservice - System B: Win 2k3 with MSSQL Server 2k5 - System C: RedHat Enterprise Server running...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.