Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 229
  • Last Modified:

connecting to MS-SQL Server 7.0

Hello, experts!
I have a simple question out here!
I faced a little problem with MSSQL error hiding...
This is my script; it checks if password or login are incorrect by trying to connect to the database, but when it can't connect it not only show's my message: "Cannot grant Access...", but also MSSQL standard message:

Warning: MS SQL message: Login failed for user 'Dmitry'. (severity 14) in C:\InetPub\wwwroot\wlr\login.php3 on line 6
Cannot grant Access to the DataBase!

So, here's the simple script:

<?php
 if ($log!="")
    if (!$conn = mssql_connect("wap", $log, $pwd)) echo "Cannot grant Access to the DataBase!";
 mssql_select_db("NorthWind",$conn) or die ("Can't select database!");    
?>

$log and $pwd are variables that are returned from previous form.

10x in advance,
[Wizz]
0
wizzard
Asked:
wizzard
  • 7
  • 6
  • 2
1 Solution
 
us111Commented:
in this function mssql_connect("wap", $log, $pwd)  you connect to the database with login and password to this database. If $log and $pwd are into a table in that database, it won't work.
You have to specify a good login and password to access the database.
Check and grant access in MSSQL.
0
 
wizzardAuthor Commented:
Khmmm... I'm not the first day with MSSQL and PHP3, and I asked concrete question ;)

repeating: "I know that I can't connect to the database with wrong l/p!"

This is my script; it checks if password or login are incorrect by trying to connect to the database, but when it can't connect it not only show's my message: "Cannot grant Access...", but also MSSQL standard message:

Warning: MS SQL message: Login failed for user 'Dmitry'. (severity 14) in C:\InetPub\wwwroot\wlr\login.php3 on line 6
Cannot grant Access to the DataBase!

IF I CAN'T CONNECT TO THE DATABASE I WISH TO GET ONLY _MY_ PART OF CODE THAT IS "Cannot grant Access..." BUT NOT THE STANDARD MSSQL ERROR (I WISH TO SHOW MY MESSAGE INSTEAD OF MSSQL ERROR):

Warning: MS SQL message: Login failed for user 'Dmitry'. (severity 14) in C:\InetPub\wwwroot\wlr\login.php3 on line 6.

For now it shows both ;)

BW,
[Wizz]
0
 
us111Commented:
ah ok ;)
I'm looking for a solution
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
wizzardAuthor Commented:
the line is incorrect in error message, for i've cut some commented lines... ;)
0
 
us111Commented:
ah ok ;)
I'm looking for a solution
0
 
us111Commented:
add @ before the function mssql_connect("wap", $log, $pwd))
so it's $conn = @mssql_connect("wap", $log, $pwd))

The @ will ignore the warning
0
 
us111Commented:
0
 
wizzardAuthor Commented:
Eeeh! ;) still it's not the complete solution, for then I don't get my error message too :(

Wizz.
0
 
maxkirCommented:
Really, I prefer such style:

<?php
    if ($log!="")
    {
        $conn = @mssql_connect("wap", $log, $pwd);
        if(!$conn)
        {
             echo "Cannot grant Access to the DataBase!";
        }
        else
        {
            mssql_select_db("NorthWind",$conn) or die ("Can't select
database!");    
        }  
?>
0
 
us111Commented:
Are you sure. I've tested with mysql, same as mssql

<?
if (!$conn = @mysql_connect("localhost", "klkilk", "uweiruo"))
        echo "Cannot grant Access to the DataBase!";
@mysql_select_db("NorthWind",$conn) or die ("Can't select database!");
?>

returns me:
Cannot grant Access to the DataBase!Can't select database!
0
 
wizzardAuthor Commented:
BTW, It DIDN'T work ;) (reg. your last comment)
So, I've changed some things and got a working version! :P

Well, Excellent Job!
Here's your "A" grade, thanks again!

BW,
Wizz.
0
 
wizzardAuthor Commented:
Oooh, us111.... it wasn't your answer... :(
Well, I'll have new questions soon!
Sorry.

Wizz.
0
 
maxkirCommented:
I'm sorry, if answer mine or not ? If it is us111's, I'm ready to post a question for him.
0
 
wizzardAuthor Commented:
;) well, maxkir, your answer was checked and worked - that's it!
10x,
Wizz.
0
 
us111Commented:
hey very bad boy :))
never mind :))
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now