Skip to Content.
Sympa Menu

freetds - Re: [freetds] PHP Mssql Connection Error: Permissions?

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Randy Syring <rsyring AT gmail.com>
  • To: derrick AT blueaxis.com, FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] PHP Mssql Connection Error: Permissions?
  • Date: Wed, 07 Sep 2011 10:08:57 -0400

set TDSDUMPCONFIG environment variable and see what params are actually being used to connect.

http://www.freetds.org/userguide/logging.htm

--------------------------------------
Randy Syring
Intelicom
Direct: 502-276-0459
Office: 502-212-9913

For the wages of sin is death, but the
free gift of God is eternal life in
Christ Jesus our Lord (Rom 6:23)


On 09/07/2011 10:05 AM, Derrick Betts wrote:
The PHP script is calling the server by NAME. The php script looks like this:

<?php

try {

$db = new
PDO('dblib:host=netWorthServer;charset=UTF-8;dbname=my_db_name',
'my_user_name', 'my_password');



foreach ($db->query('SELECT * from users') as $row) {

print_r($row);

}

$db = null;

} catch (PDOException $e) {

print "Error!: " . $e->getMessage() . "<br/>";

die();

}

?>



The freetds.conf file looks like this:

[netWorthServer]

host = 10.0.20.100

port = 1433

tds version = 7.2



From: Armando Ortiz [mailto:Armando.Ortiz AT cppcorp.com]
Sent: Wednesday, September 07, 2011 8:02 AM
To: derrick AT blueaxis.com; FreeTDS Development Group
Subject: RE: [freetds] PHP Mssql Connection Error: Permissions?



Are you calling the server by name or by IP address?



From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Derrick Betts
Sent: Wednesday, September 07, 2011 6:57 AM
To: 'FreeTDS Development Group'
Subject: Re: [freetds] PHP Mssql Connection Error: Permissions?



Thank you for your reply.

So I can run the php script as apache on the command line like this:



-bash-3.2$ PHP /var/www/html/axis/public/test.php



And the php script pulls all the data from the DB just like I would expect it
to. However, if I run the same script from the browser, I get the following
error:



SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not
exist (severity 9)



From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Thomas, Christopher
(LLU)
Sent: Tuesday, September 06, 2011 11:24 PM
To: FreeTDS Development Group
Subject: Re: [freetds] PHP Mssql Connection Error: Permissions?



When you say the script fails, what do you mean by that? Do you get any error
msgs? If so what are they?



Chris



_____

From: freetds-bounces AT lists.ibiblio.org on behalf of Derrick Betts
Sent: Tue 9/6/2011 4:49 PM
To: freetds AT lists.ibiblio.org
Subject: [freetds] PHP Mssql Connection Error: Permissions?

I have a PHP script that makes a connection to SQL Server.

> From the command line as root: tsql -H hostname -U username connects just
great and I can run queries.



I have a PHP script in /var/www/html/axis/public/test.php

When I: sudo -u apache -s (change the user from root to apache) and then run
my PHP script from the command line, it connects just great.

But, from the web browser, it fails. The web browser is able to connect
everywhere it is supposed to and renders all the web pages that don't need
an SQL connection.



apache is the user that is running httpd. I've confirmed this via: ps aux |
grep apache



Any ideas as to why apache can run the PHP script and connect just fine from
the command line, but when the browser attempts to connect to the very same
script, it fails?



Thanks,

Derrick

_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds



_____

---------------
CONFIDENTIALITY WARNING: This email may contain privileged or confidential
information and is for the sole use of the intended recipients. Unauthorized
disclosure or use of this communication is prohibited. If you believe that
you have received this email in error, please notify the sender immediately
and delete it from your system.

EXPORT WARNING: These commodities, technical data or software may be subject
to the export control of either the International Traffic in Arms Regulations
(ITAR) or the Export Administration Regulations (EAR) and may not be exported
without the authorization of either the Department of State or the Department
of Commerce prior to export. Export includes disclosure and or access to
Commodities, technical data or software by foreign nationals whether located
in the United States or Abroad. This requirement applies equally to foreign
national employees of U.S. Companies and their foreign subsidiaries.

_______________________________________________
FreeTDS mailing list
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page