php-windows Digest 19 Jun 2008 07:32:10 -0000 Issue 3487
Topics (messages 28937 through 28941):
Re: MSSQL and ODBC Connections with PHP on Windows
28937 by: Zephaniah ha Levi
28938 by: Sascha Meyer
28939 by: Wei, Alice J.
28940 by: Wei, Alice J.
28941 by: Eric
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 ---
Why use odbc?
Why not something like:
$server = "localhost";
$username = "USER";
$password = "Password";
$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb = mssql_select_db("DB", $sqlconnect);
$SqlSelectData = "select * from tablename";
$results = mssql_query($SqlSelectData);
while($nameresults = mssql_fetch_array($results)){
$Name = $namereults(['Name']);
echo "$Name<br>";
}
Mssql_Close($sqlconnect)
Or somethignt like that. You need to make sure that the mssql extension is
loaded in your php.ini.
-----Original Message-----
From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 10:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
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]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I would recommend using PDO for MSSQL, because it performs better in most.
You have to enable both php_pdo.dll and php_pdo_mssql.dll in your php.ini,
restart the web server and you should be ready to go.
Here's a sample code taken from http://de.php.net/manual/en/ref.pdo-dblib.php
[CODE]
<?php
try {
$hostname = "myhost";
$port = 1433;
$dbname = "tempdb";
$username = "dbuser";
$pw = "password";
$dbh = new PDO
("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "\n";
exit;
}
$stmt = $dbh->prepare("select name from master..sysdatabases where name =
db_name()");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>
[/CODE]
I especially like the fetchAll() function, that's really fast!
Best regards,
Sascha
--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
--- End Message ---
--- Begin Message ---
Hi,
Using the mssql connection has so far given me more trouble, and I did use
your code, which only gives me error messages. I did try to telnet it to make
sure that the server exists, and I was in.
Here is the code:
<html>
<head>
<title>PHP SQL Database</title>
</head>
<body>
<?php
echo "<p>hello</p>";
$server = "localhost,1433";
$username = "username";
$password = "pass";
$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb = mssql_select_db("mydb", $sqlconnect);
$SqlSelectData = "select Name from patient";
$results = mssql_query($SqlSelectData);
while($nameresults = mssql_fetch_array($results)){
$Name = $namereults['Name'];
echo "<p>Here are the results:</p>";
echo "<p>$Name<br>";
$n++;
}
mssql_close($sqlconnect);
?>
</body>
</html>
In my php.ini file, extension=php_mssql.dll was downloaded and loaded into
C:/PHP/ext. I have added a line to give me errors, and it does pop up a window
that says mssql was loaded. Therefore, does this mean that my extension is
working? Or, is there is any glitch for me to see additonal error reports to
show what kind of error I may be really getting?
Thanks in advance.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
________________________________________
From: Zephaniah ha Levi [EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 10:53 AM
To: Wei, Alice J.; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Why use odbc?
Why not something like:
$server = "localhost";
$username = "USER";
$password = "Password";
$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb = mssql_select_db("DB", $sqlconnect);
$SqlSelectData = "select * from tablename";
$results = mssql_query($SqlSelectData);
while($nameresults = mssql_fetch_array($results)){
$Name = $namereults(['Name']);
echo "$Name<br>";
}
Mssql_Close($sqlconnect)
Or somethignt like that. You need to make sure that the mssql extension is
loaded in your php.ini.
-----Original Message-----
From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 10:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
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]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Hi,
Thanks for the follow up.
To answer your questions,
1) I see no additional errors other than the messages after what I have set
up for "Can't Connect to server" as appeared in my error after it dies from the
connection.
2) and 3) Therefore, I cannot connect or even select a database at all, not
even to mention that this means I cannot retrieve the data from the data source.
Does this give you more information of why am I not getting any data output or
trouble with connections?
Alice
-----Original Message-----
From: Eric Lee [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 6:55 PM
To: Wei, Alice J.; Zephaniah ha Levi; [EMAIL PROTECTED]
Subject: Re: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Hi,
Could you able detail the errors ?
I am prefer a method that seperate the connection steps as
1.) Could you able connection to the server without error ?
2.) Able to select a different database ?
3.) get the data from database you need to use.
It is best also provide the error messages that displayed on your screen.
Regards,
Eric
:
:----- Original Message -----
:From: "Wei, Alice J." <[EMAIL PROTECTED]>
:To: "Zephaniah ha Levi" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
:Sent: Thursday, June 19, 2008 4:47 AM
:Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
:
:
:Hi,
:
: Using the mssql connection has so far given me more trouble, and I did use
your code, which only gives me error messages. I did try to telnet it to make
sure that the server exists, and I was in.
:
:Here is the code:
:
:<html>
:<head>
:<title>PHP SQL Database</title>
:</head>
:<body>
:<?php
:echo "<p>hello</p>";
:$server = "localhost,1433";
:$username = "username";
:$password = "pass";
:$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
:Connect to server.");
:$sqldb = mssql_select_db("mydb", $sqlconnect);
:$SqlSelectData = "select Name from patient";
:$results = mssql_query($SqlSelectData);
:while($nameresults = mssql_fetch_array($results)){
:$Name = $namereults['Name'];
:echo "<p>Here are the results:</p>";
:echo "<p>$Name<br>";
:$n++;
:}
:mssql_close($sqlconnect);
:?>
:</body>
:</html>
:
:In my php.ini file, extension=php_mssql.dll was downloaded and loaded into
C:/PHP/ext. I have added a line to give me errors, and it does pop up a window
that says mssql was loaded. Therefore, does this mean that my extension is
working? Or, is there is any glitch for me to see additonal error reports to
show what kind of error I may be really getting?
:
:Thanks in advance.
:
:Alice
:======================================================
:Alice Wei
:MIS 2009
:School of Library and Information Science
:Indiana University Bloomington
:[EMAIL PROTECTED]
:________________________________________
:From: Zephaniah ha Levi [EMAIL PROTECTED]
:Sent: Wednesday, June 18, 2008 10:53 AM
:To: Wei, Alice J.; [EMAIL PROTECTED]
:Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
:
:Why use odbc?
:Why not something like:
:
:$server = "localhost";
:$username = "USER";
:$password = "Password";
:$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
:Connect to server.");
:
:$sqldb = mssql_select_db("DB", $sqlconnect);
:$SqlSelectData = "select * from tablename";
:$results = mssql_query($SqlSelectData);
:
:while($nameresults = mssql_fetch_array($results)){
: $Name = $namereults(['Name']);
:echo "$Name<br>";
:}
:Mssql_Close($sqlconnect)
:
:
:Or somethignt like that. You need to make sure that the mssql extension is
:loaded in your php.ini.
:-----Original Message-----
:From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
:Sent: Wednesday, June 18, 2008 10:45 AM
:To: [EMAIL PROTECTED]
:Subject: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
:
: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]
:
:--
:PHP Windows Mailing List (http://www.php.net/)
:To unsubscribe, visit: http://www.php.net/unsub.php
:
:--
:PHP Windows Mailing List (http://www.php.net/)
:To unsubscribe, visit: http://www.php.net/unsub.php
:
--- End Message ---
--- Begin Message ---
Please download this newer ntwdblib.dll from here
http://myprojects.srhost.info/download/ntwdblib.zip
and place this file into %systemroot%\system32 folder
Also, do you use intergrated auth. or mixed auth mode of mssql server auth. ?
----- Original Message -----
From: "Wei, Alice J." <[EMAIL PROTECTED]>
To: "Zephaniah ha Levi" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, June 19, 2008 4:47 AM
Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Hi,
Using the mssql connection has so far given me more trouble, and I did use
your code, which only gives me error messages. I did try to telnet it to make
sure that the server exists, and I was in.
Here is the code:
<html>
<head>
<title>PHP SQL Database</title>
</head>
<body>
<?php
echo "<p>hello</p>";
$server = "localhost,1433";
$username = "username";
$password = "pass";
$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb = mssql_select_db("mydb", $sqlconnect);
$SqlSelectData = "select Name from patient";
$results = mssql_query($SqlSelectData);
while($nameresults = mssql_fetch_array($results)){
$Name = $namereults['Name'];
echo "<p>Here are the results:</p>";
echo "<p>$Name<br>";
$n++;
}
mssql_close($sqlconnect);
?>
</body>
</html>
In my php.ini file, extension=php_mssql.dll was downloaded and loaded into
C:/PHP/ext. I have added a line to give me errors, and it does pop up a window
that says mssql was loaded. Therefore, does this mean that my extension is
working? Or, is there is any glitch for me to see additonal error reports to
show what kind of error I may be really getting?
Thanks in advance.
Alice
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
[EMAIL PROTECTED]
________________________________________
From: Zephaniah ha Levi [EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 10:53 AM
To: Wei, Alice J.; [EMAIL PROTECTED]
Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Why use odbc?
Why not something like:
$server = "localhost";
$username = "USER";
$password = "Password";
$sqlconnect = mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb = mssql_select_db("DB", $sqlconnect);
$SqlSelectData = "select * from tablename";
$results = mssql_query($SqlSelectData);
while($nameresults = mssql_fetch_array($results)){
$Name = $namereults(['Name']);
echo "$Name<br>";
}
Mssql_Close($sqlconnect)
Or somethignt like that. You need to make sure that the mssql extension is
loaded in your php.ini.
-----Original Message-----
From: Wei, Alice J. [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 18, 2008 10:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
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]
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---