Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

connecting to MS-SQL Server 7.0

Posted on 2000-03-22
15
Medium Priority
?
225 Views
Last Modified: 2008-03-10
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
Comment
Question by:wizzard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
15 Comments
 
LVL 8

Expert Comment

by:us111
ID: 2643900
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
 

Author Comment

by:wizzard
ID: 2643930
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
 
LVL 8

Expert Comment

by:us111
ID: 2644000
ah ok ;)
I'm looking for a solution
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:wizzard
ID: 2644006
the line is incorrect in error message, for i've cut some commented lines... ;)
0
 
LVL 8

Expert Comment

by:us111
ID: 2644012
ah ok ;)
I'm looking for a solution
0
 
LVL 8

Expert Comment

by:us111
ID: 2644130
add @ before the function mssql_connect("wap", $log, $pwd))
so it's $conn = @mssql_connect("wap", $log, $pwd))

The @ will ignore the warning
0
 
LVL 8

Expert Comment

by:us111
ID: 2644134
0
 

Author Comment

by:wizzard
ID: 2644149
Eeeh! ;) still it's not the complete solution, for then I don't get my error message too :(

Wizz.
0
 
LVL 2

Accepted Solution

by:
maxkir earned 200 total points
ID: 2644223
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
 
LVL 8

Expert Comment

by:us111
ID: 2644250
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
 

Author Comment

by:wizzard
ID: 2644269
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
 

Author Comment

by:wizzard
ID: 2644290
Oooh, us111.... it wasn't your answer... :(
Well, I'll have new questions soon!
Sorry.

Wizz.
0
 
LVL 2

Expert Comment

by:maxkir
ID: 2644355
I'm sorry, if answer mine or not ? If it is us111's, I'm ready to post a question for him.
0
 

Author Comment

by:wizzard
ID: 2644394
;) well, maxkir, your answer was checked and worked - that's it!
10x,
Wizz.
0
 
LVL 8

Expert Comment

by:us111
ID: 2644498
hey very bad boy :))
never mind :))
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question