php-windows Digest 18 Jun 2008 14:45:36 -0000 Issue 3486
Topics (messages 28929 through 28936):
Re: PHP and MSSQL Connection on IIS 5.1
28929 by: Elizabeth M Smith
28930 by: Wei, Alice J.
28931 by: Elizabeth M Smith
28932 by: Wei, Alice J.
28933 by: Wei, Alice J.
CuRL
28934 by: Bryan
28935 by: Philip Olson
MSSQL and ODBC Connections with PHP on Windows
28936 by: Wei, Alice J.
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Wei, Alice J. wrote:
> Hi, Guys:
>
> This is my first time running PHP 5.2 on a IIS 5.1 Server using a Windows
> XP machine.
> My client wants me to build the PHP scripts and the database on one single
> machine. So far I could run the PHP fine, but I am having a hard time
> connecting to the MSSQL database even though it is on one machine.
>
> I have created a freetds.conf file and have it set in the Windows directory
> in the following format:
>
> [global]
> host = 192.168.10.62
> port = 1433
> client charset = UTF-8
> tds version = 8.0
> text size = 20971520
>
> I have then went into C:\Inetpub\wwwroot\test and built a index.php script,
> with my code as follows:
>
> <html>
> <head>
> <title>PHP Test</title>
> </head>
> <body>
> <?php
> echo "<p>Hello!</p>";
> $myServer = "global";
> $myUser = "user";
> $myPass = "password";
> $myDB = "books";
> // connection to the database
> $dbhandle = mssql_connect($myServer, $myUser, $myPass)
> or die("Couldn't connect to SQL Server on $myServer");
> // select a database to work with
> $selected = mssql_select_db($myDB, $dbhandle)
> or die("Couldn't open database $myDB");
> echo "You are connected to the " . $myDB . " database on the " . $myServer .
> ".";
> // close the connection
> mssql_close($dbhandle);
> ?>
> </body>
> </html>
>
> So far I only get this from the screen:
>
> Hello!
> Couldn't connect to SQL Server on global
>
> Is there anything else I have missed? I have followed the prompts of
> installing FreeTDS according to
> http://docs.moodle.org/en/Installing_MSSQL_for_PHP, Would anyone say if I use
> something like ODBC would work better?
>
> I welcome any suggestions.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
I've found that ODBC or PDO_ODBC works much better with Microsoft SQL if
PHP is on windows - the native client driver odbc connection string
works really well with MSSQL 2005 ;) Usually freetds is only needed if
you need to connect from a linux box with PHP to a windows box with mssql.
Thanks,
Elizabeth
--- End Message ---
--- Begin Message ---
Hi,
For ODBC connections, are you using MSSQL 2005? I am currently using Windows
XP for the server with PHP 5.2.
I am currently using this version of the MS SQL server, and thus when I am
seting up the ODBC connection, I notice that it keeps failing possibly because
the SQL Server is indicated as 2000 and not even 2003. Would this make a
difference?
Thanks in advance.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
________________________________________
From: Elizabeth M Smith [EMAIL PROTECTED]
Sent: Tuesday, June 17, 2008 3:58 PM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Re: PHP and MSSQL Connection on IIS 5.1
Wei, Alice J. wrote:
> Hi, Guys:
>
> This is my first time running PHP 5.2 on a IIS 5.1 Server using a Windows
> XP machine.
> My client wants me to build the PHP scripts and the database on one single
> machine. So far I could run the PHP fine, but I am having a hard time
> connecting to the MSSQL database even though it is on one machine.
>
> I have created a freetds.conf file and have it set in the Windows directory
> in the following format:
>
> [global]
> host = 192.168.10.62
> port = 1433
> client charset = UTF-8
> tds version = 8.0
> text size = 20971520
>
> I have then went into C:\Inetpub\wwwroot\test and built a index.php script,
> with my code as follows:
>
> <html>
> <head>
> <title>PHP Test</title>
> </head>
> <body>
> <?php
> echo "<p>Hello!</p>";
> $myServer = "global";
> $myUser = "user";
> $myPass = "password";
> $myDB = "books";
> // connection to the database
> $dbhandle = mssql_connect($myServer, $myUser, $myPass)
> or die("Couldn't connect to SQL Server on $myServer");
> // select a database to work with
> $selected = mssql_select_db($myDB, $dbhandle)
> or die("Couldn't open database $myDB");
> echo "You are connected to the " . $myDB . " database on the " . $myServer .
> ".";
> // close the connection
> mssql_close($dbhandle);
> ?>
> </body>
> </html>
>
> So far I only get this from the screen:
>
> Hello!
> Couldn't connect to SQL Server on global
>
> Is there anything else I have missed? I have followed the prompts of
> installing FreeTDS according to
> http://docs.moodle.org/en/Installing_MSSQL_for_PHP, Would anyone say if I use
> something like ODBC would work better?
>
> I welcome any suggestions.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
I've found that ODBC or PDO_ODBC works much better with Microsoft SQL if
PHP is on windows - the native client driver odbc connection string
works really well with MSSQL 2005 ;) Usually freetds is only needed if
you need to connect from a linux box with PHP to a windows box with mssql.
Thanks,
Elizabeth
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Wei, Alice J. wrote:
> Hi,
>
> For ODBC connections, are you using MSSQL 2005? I am currently using
> Windows XP for the server with PHP 5.2.
>
> I am currently using this version of the MS SQL server, and thus when I am
> seting up the ODBC connection, I notice that it keeps failing possibly
> because the SQL Server is indicated as 2000 and not even 2003. Would this
> make a difference?
>
> Thanks in advance.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
> _____________________
As long as you're using the right odbc connection string it shouldn't
matter - you shouldn't have to use a dsn even -
www.connectionstrings.com/?carrier=sqlserver has a nice listing of how
you should be formatting your connection strings
Remember that you need to be able to have permission to connect to the
database! For PHP the easiest way to do this is to get TCP/IP working
for sqlserver and using sql level authentication, not windows
authentication. You'll have to get into the client tools to get this
working properly, and it's been long enough since I had to mess with it
that I don't remember exactly where those settings are.
Thanks,
Elizabeth
--- End Message ---
--- Begin Message ---
Hi,
Thanks for the document. I have used the Administrative Tools to create a new
ODBC data source, and it has been shown that the tests has been done
successfully from the System DSN.
My next question is this, with my ODBC driver compiled successfully, this is
the connection string I have established to connect to the database using ODBC
connection.
$connection_string = 'DRIVER={SQL Server};SERVER=localhost;DATABASE=master';
$user = 'user';
$pass = 'xxxxx';
odbc_connect($connection_string, $user, $pass) or die ("Cannot connect to
database");
echo "You are connected to the database';
However, this has so far never given me any success. As I mentioned before,
since this PHP script would be stored on the same server as the database, I
only have to indicate the server as localhost, as I have had in the ODBC
connection, right?
Or, is there anything else I have missed?
Thanks for your help.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
________________________________________
From: Elizabeth M Smith [EMAIL PROTECTED]
Sent: Tuesday, June 17, 2008 4:39 PM
To: Wei, Alice J.
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Re: PHP and MSSQL Connection on IIS 5.1
Wei, Alice J. wrote:
> Hi,
>
> For ODBC connections, are you using MSSQL 2005? I am currently using
> Windows XP for the server with PHP 5.2.
>
> I am currently using this version of the MS SQL server, and thus when I am
> seting up the ODBC connection, I notice that it keeps failing possibly
> because the SQL Server is indicated as 2000 and not even 2003. Would this
> make a difference?
>
> Thanks in advance.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
> _____________________
As long as you're using the right odbc connection string it shouldn't
matter - you shouldn't have to use a dsn even -
www.connectionstrings.com/?carrier=sqlserver has a nice listing of how
you should be formatting your connection strings
Remember that you need to be able to have permission to connect to the
database! For PHP the easiest way to do this is to get TCP/IP working
for sqlserver and using sql level authentication, not windows
authentication. You'll have to get into the client tools to get this
working properly, and it's been long enough since I had to mess with it
that I don't remember exactly where those settings are.
Thanks,
Elizabeth
--- End Message ---
--- Begin Message ---
Hi,
Thanks for the document. I have used the Administrative Tools to create a new
ODBC data source, and it has been shown that the tests has been done
successfully from the System DSN.
My next question is this, with my ODBC driver compiled successfully, this is
the connection string I have established to connect to the database using ODBC
connection.
$connection_string = 'DRIVER={SQL Server};SERVER=localhost;DATABASE=master';
$user = 'user';
$pass = 'xxxxx';
odbc_connect($connection_string, $user, $pass) or die ("Cannot connect to
database");
echo "You are connected to the database';
However, this has so far never given me any success. As I mentioned before,
since this PHP script would be stored on the same server as the database, I
only have to indicate the server as localhost, as I have had in the ODBC
connection, right?
Or, is there anything else I have missed?
Thanks for your help.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
________________________________________
From: Elizabeth M Smith [EMAIL PROTECTED]
Sent: Tuesday, June 17, 2008 4:39 PM
To: Wei, Alice J.
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] Re: PHP and MSSQL Connection on IIS 5.1
Wei, Alice J. wrote:
> Hi,
>
> For ODBC connections, are you using MSSQL 2005? I am currently using
> Windows XP for the server with PHP 5.2.
>
> I am currently using this version of the MS SQL server, and thus when I am
> seting up the ODBC connection, I notice that it keeps failing possibly
> because the SQL Server is indicated as 2000 and not even 2003. Would this
> make a difference?
>
> Thanks in advance.
>
> Alice
> ======================================================
> Alice Wei
> MIS 2009
> School of Library and Information Science
> Indiana University Bloomington
> [EMAIL PROTECTED]
> _____________________
As long as you're using the right odbc connection string it shouldn't
matter - you shouldn't have to use a dsn even -
www.connectionstrings.com/?carrier=sqlserver has a nice listing of how
you should be formatting your connection strings
Remember that you need to be able to have permission to connect to the
database! For PHP the easiest way to do this is to get TCP/IP working
for sqlserver and using sql level authentication, not windows
authentication. You'll have to get into the client tools to get this
working properly, and it's been long enough since I had to mess with it
that I don't remember exactly where those settings are.
Thanks,
Elizabeth
--- End Message ---
--- Begin Message ---
I cannot get the curl commands to work in Windows. I am using WAMP 5.
Can anyone point me in the right direction on how to get it working?
--- End Message ---
--- Begin Message ---
On 6/17/08, Bryan <[EMAIL PROTECTED]> wrote:
>
> I cannot get the curl commands to work in Windows. I am using WAMP 5. Can
> anyone point me in the right direction on how to get it working?
You must enable the appropriate dll files (php_curl.dll) inside php.ini. See
also the following for additional details (and DLL files):
http://php.net/curl.installation
Then, restart your web server.
Regards,
Philip
--- End Message ---
--- Begin Message ---
Hi,
I am a newbie using the combination of PHP and MSSQL together.
Can anyone tell me which method it might be better as far as using PHP on
Windows with MSSQL database on a single machine? (The PHP and MSSQL database
are not set up remotely on two different servers.
I have set up both, and my ODBC Driver does work when I run it from the
test without using PHP, and yet when I put it in PHP, my entire screen goes
blank.
$dsn="MSSQL";
$username="user";
$password="password";
$sqlconnect=odbc_connect($dsn,$username,$password);
$sqlquery="SELECT title FROM books";
$process=odbc_exec($sqlconnect, $sqlquery);
while(odbc_fetch_row($process)){
$Name = odbc_result($process,"Name");
echo "$Name<br>"; }
odbc_close($sqlconnect);
The similar thing happens when I use the code by using a slight modification
from http://us3.php.net/manual/en/function.mssql-connect.php.
Can anyone please provide me some tips and solutions on what additional modules
or set up I need to get this to work? I was told that if I use Windows, I may
not have to use FreeTDS.
Thanks in advance.
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
--- End Message ---