Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

call to undefined function mssql_connect()

mssql

  • Please log in to reply
8 replies to this topic

#1 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 20 September 2010 - 05:02 PM

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


i already enable extension mssql in php.ini
  • 0

#2 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 20 September 2010 - 09:07 PM

Can you verify with phpinfo(); that MSSQL support is installed and enabled?
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 20 September 2010 - 09:31 PM

how can i verify?

when i run phpinfo();

the result is Webpage cannot be displayed
  • 0

#4 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 20 September 2010 - 10:04 PM

With this?
<?php
phpinfo();
?>


There should be an MSSQL section with the library used. Note that safemode needs to be turned off.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#5 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 20 September 2010 - 10:51 PM

i have that and when i run it .Page cannot be displayed is the result
  • 0

#6 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 20 September 2010 - 11:02 PM

It seems to be a bug with Windows vs. Apache 2 when PHP is run as a module:
PHP :: Bug #22983 :: Page Cannot Be Displayed

Try installing PHP as CGI (assuming it isn't.) or latest Apache/PHP and see if the problem persists.
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#7 newphpcoder

newphpcoder

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 527 posts

Posted 29 September 2010 - 05:26 PM

It seems to be a bug with Windows vs. Apache 2 when PHP is run as a module:
PHP :: Bug #22983 :: Page Cannot Be Displayed

Try installing PHP as CGI (assuming it isn't.) or latest Apache/PHP and see if the problem persists.


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
//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
  • 0

#8 Orjan

Orjan

    CC Mentor

  • Moderator
  • 2918 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#

Posted 29 September 2010 - 09:23 PM

have you activated the extension php_mssql.dll ?
  • 0

I'm a System developer at XLENT Consultant Group mainly working with SugarCRM.
Please DO NOT send mail or PM to me with programming questions, post them in the appropriate forum instead, where I and others can answer you.


#9 DEViANT

DEViANT

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 265 posts

Posted 01 October 2010 - 11:08 PM

Just Install Wamp.
  • 0

:D You should rep+ me so that I can win :D

My Blog | Ask me!
Error : Satan did it





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download