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");
}
$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);
And look at the output to see if the module is reported as installed.
I asked if the line was commented out because in some installs it ends up commented out by default. If the line is commented out, the module won't be loaded, so you want to make sure it is NOT commented out.
And look at the output to see if the module is reported as installed.
I asked if the line was commented out because in some installs it ends up commented out by default. If the line is commented out, the module won't be loaded, so you want to make sure it is NOT commented out.
the extension mssql has ; and i delete it.
and i try the php_info()
but the result is the page cannot be found.
Create a page in the same directory as the other php files you are working on. Call it info.php. In that file just put
Code:
<?php
php_info()
?>
The go to your browser and go to that page. If you get a message that the page is not found, you either put the page in the wrong place or pointed your browser at the wrong place.
You should get a bunch of output that will give you information about your php configuration.
Create a page in the same directory as the other php files you are working on. Call it info.php. In that file just put
Code:
<?php
php_info()
?>
The go to your browser and go to that page. If you get a message that the page is not found, you either put the page in the wrong place or pointed your browser at the wrong place.
You should get a bunch of output that will give you information about your php configuration.
I'm sure wiht the location of phpinfo but still the page cannot be displayed.
Is it theres a problem with the php version that i have because it is not compatible with mssql?
I'm sure wiht the location of phpinfo but still the page cannot be displayed.
Is it theres a problem with the php version that i have because it is not compatible with mssql?
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]
$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);
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
The correct command is "phpinfo();" without the underscore, with the () and although the semi-colon on the end isn't required if its the only command in the script, it's good habit to add it. How can something so easy result in so many comments!
Secondly, for Windows web servers the extension needs to be enabled (uncommented) in php.ini, and then the web server needs to be restarted to pick up the change. It's that simple. Don't mess with the other MSSQL settings unless you know the extension is properly loaded, the PHP code is valid, but still errors and you know what you're doing. I mean to say things like "simply copy ntwdblib.dll from c:\php to c:\windows" might be necessary, but its rare these days.
FYI -- You can also run "php -m" via command line in a command shell if a PHP CLI was installed and view the loaded modules that way, i.e. you'll see "MSSQL" included in the list. In Windows just run the command, in *nix type "which php" to get the path if it doesn't work the first time or you want to check to see if the CLI daemon exists.
-jim
Last edited by SrWebDeveloper; 10-21-2010 at 11:22 AM.
Reason: fixed typo
Jim, Sr. Web Developer You know who you real friends are when you ask them to move your furniture or paint.
I know it might be rare to have it in a different location, but every time I have helped someone with this very issue, they had the extension = php_mssql.dll uncommented, they modified the correct php.ini, and the mssql (btw basically same issue with mysql) doesn't load. It was because the configuration file path was not to c:\php. The php.ini was loading correctly, but it did not see the required dll files to run what it needed, so it bypassed it.
Again, it's rare, but it can happen. He seems to have done everything else right, so it could be that issue.
Bookmarks