MSSQL and ODBC Connections with PHP on Windows
MSSQL and ODBC Connections with PHP on Windows
am 18.06.2008 16:45:15 von ajwei
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 o=
n Windows with MSSQL database on a single machine? (The PHP and MSSQL datab=
ase 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 goe=
s blank.
$dsn=3D"MSSQL";
$username=3D"user";
$password=3D"password";
$sqlconnect=3Dodbc_connect($dsn,$username,$password);
$sqlquery=3D"SELECT title FROM books";
$process=3Dodbc_exec($sqlconnect, $sqlquery);
while(odbc_fetch_row($process)){
$Name =3D odbc_result($process,"Name");
echo "$Name
"; }
odbc_close($sqlconnect);
The similar thing happens when I use the code by using a slight modificatio=
n from http://us3.php.net/manual/en/function.mssql-connect.php.
Can anyone please provide me some tips and solutions on what additional mod=
ules 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.
==================== =====3D=
==================== =====3D=
====
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: MSSQL and ODBC Connections with PHP on Windows
am 18.06.2008 16:53:16 von Zleviticus
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
";
}
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:ajwei@indiana.edu]
Sent: Wednesday, June 18, 2008 10:45 AM
To: php-windows@lists.php.net
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
"; }
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
ajwei@indiana.edu
--
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
Re: MSSQL and ODBC Connections with PHP on Windows
am 18.06.2008 17:27:55 von harlequin2
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]
try {
$hostname = "myhost";
$port = 1433;
$dbname = "tempdb";
$username = "dbuser";
$pw = "password";
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$p w");
} 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
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: MSSQL and ODBC Connections with PHP on Windows
am 18.06.2008 22:47:49 von ajwei
Hi,
Using the mssql connection has so far given me more trouble, and I did us=
e 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:
PHP SQL Database
echo "hello
";
$server =3D "localhost,1433";
$username =3D "username";
$password =3D "pass";
$sqlconnect =3D mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb =3D mssql_select_db("mydb", $sqlconnect);
$SqlSelectData =3D "select Name from patient";
$results =3D mssql_query($SqlSelectData);
while($nameresults =3D mssql_fetch_array($results)){
$Name =3D $namereults['Name'];
echo "Here are the results:
";
echo "$Name
";
$n++;
}
mssql_close($sqlconnect);
?>
In my php.ini file, extension=3Dphp_mssql.dll was downloaded and loaded int=
o C:/PHP/ext. I have added a line to give me errors, and it does pop up a w=
indow that says mssql was loaded. Therefore, does this mean that my extensi=
on is working? Or, is there is any glitch for me to see additonal error rep=
orts to show what kind of error I may be really getting?
Thanks in advance.
Alice
==================== =====3D=
==================== =====3D=
====
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu
________________________________________
From: Zephaniah ha Levi [zleviticus@fitnessnow.org]
Sent: Wednesday, June 18, 2008 10:53 AM
To: Wei, Alice J.; php-windows@lists.php.net
Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Why use odbc?
Why not something like:
$server =3D "localhost";
$username =3D "USER";
$password =3D "Password";
$sqlconnect =3D mssql_connect($server, $username, $password) or DIE("Can't
Connect to server.");
$sqldb =3D mssql_select_db("DB", $sqlconnect);
$SqlSelectData =3D "select * from tablename";
$results =3D mssql_query($SqlSelectData);
while($nameresults =3D mssql_fetch_array($results)){
$Name =3D $namereults(['Name']);
echo "$Name
";
}
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:ajwei@indiana.edu]
Sent: Wednesday, June 18, 2008 10:45 AM
To: php-windows@lists.php.net
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 o=
n
Windows with MSSQL database on a single machine? (The PHP and MSSQL databas=
e
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=3D"MSSQL";
$username=3D"user";
$password=3D"password";
$sqlconnect=3Dodbc_connect($dsn,$username,$password);
$sqlquery=3D"SELECT title FROM books";
$process=3Dodbc_exec($sqlconnect, $sqlquery);
while(odbc_fetch_row($process)){
$Name =3D odbc_result($process,"Name");
echo "$Name
"; }
odbc_close($sqlconnect);
The similar thing happens when I use the code by using a slight modificatio=
n
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.
==================== =====3D=
==================== =====3D=
====
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu
--
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
RE: MSSQL and ODBC Connections with PHP on Windows
am 19.06.2008 04:10:27 von ajwei
SGksDQoNCiAgIFRoYW5rcyBmb3IgdGhlIGZvbGxvdyB1cC4NCiAgIFRvIGFu c3dlciB5b3VyIHF1
ZXN0aW9ucywNCg0KICAgMSkgSSBzZWUgbm8gYWRkaXRpb25hbCBlcnJvcnMg b3RoZXIgdGhhbiB0
aGUgbWVzc2FnZXMgYWZ0ZXIgd2hhdCBJIGhhdmUgc2V0IHVwIGZvciAiQ2Fu J3QgQ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QvbWFu
dWFsL2VuL2Z1bmN0aW9uLm1zc3FsLWNvbm5lY3QucGhwLg0KOg0KOkNhbiBh bnlvbmUgcGxlYXNl
IHByb3ZpZGUgbWUgc29tZSB0aXBzIGFuZCBzb2x1dGlvbnMgb24gd2hhdCBh ZGRpdGlvbmFsDQo6
bW9kdWxlcyBvciBzZXQgdXAgSSBuZWVkIHRvIGdldCB0aGlzIHRvIHdvcms/ IEkgd2FzIHRvbGQg
dGhhdCBpZiBJIHVzZQ0KOldpbmRvd3MsIEkgbWF5IG5vdCBoYXZlIHRvIHVz ZSBGcmVlVERTLg0K
Og0KOlRoYW5rcyBpbiBhZHZhbmNlLg0KOj09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PQ0KOkFsaWNlIFdlaQ0KOk1JUyAyMDA5 DQo6U2Nob29sIG9m
IExpYnJhcnkgYW5kIEluZm9ybWF0aW9uIFNjaWVuY2UNCjpJbmRpYW5hIFVu aXZlcnNpdHkgQmxv
b21pbmd0b24NCjphandlaUBpbmRpYW5hLmVkdQ0KOg0KOi0tDQo6UEhQIFdp bmRvd3MgTWFpbGlu
ZyBMaXN0IChodHRwOi8vd3d3LnBocC5uZXQvKQ0KOlRvIHVuc3Vic2NyaWJl LCB2aXNpdDogaHR0
cDovL3d3dy5waHAubmV0L3Vuc3ViLnBocA0KOg0KOi0tDQo6UEhQIFdpbmRv d3MgTWFpbGluZyBM
aXN0IChodHRwOi8vd3d3LnBocC5uZXQvKQ0KOlRvIHVuc3Vic2NyaWJlLCB2 aXNpdDogaHR0cDov
L3d3dy5waHAubmV0L3Vuc3ViLnBocA0KOg0K
Re: MSSQL and ODBC Connections with PHP on Windows
am 19.06.2008 09:31:59 von Eric
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 -----=20
From: "Wei, Alice J."
To: "Zephaniah ha Levi" ; =
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:
PHP SQL Database
echo "hello
";
$server =3D "localhost,1433";
$username =3D "username";
$password =3D "pass";
$sqlconnect =3D mssql_connect($server, $username, $password) or =
DIE("Can't
Connect to server.");
$sqldb =3D mssql_select_db("mydb", $sqlconnect);
$SqlSelectData =3D "select Name from patient";
$results =3D mssql_query($SqlSelectData);
while($nameresults =3D mssql_fetch_array($results)){
$Name =3D $namereults['Name'];
echo "Here are the results:
";
echo "$Name
";
$n++;
}
mssql_close($sqlconnect);
?>
In my php.ini file, extension=3Dphp_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
==================== =====3D=
==================== =====3D=
====
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu
________________________________________
From: Zephaniah ha Levi [zleviticus@fitnessnow.org]
Sent: Wednesday, June 18, 2008 10:53 AM
To: Wei, Alice J.; php-windows@lists.php.net
Subject: RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
Why use odbc?
Why not something like:
$server =3D "localhost";
$username =3D "USER";
$password =3D "Password";
$sqlconnect =3D mssql_connect($server, $username, $password) or =
DIE("Can't
Connect to server.");
$sqldb =3D mssql_select_db("DB", $sqlconnect);
$SqlSelectData =3D "select * from tablename";
$results =3D mssql_query($SqlSelectData);
while($nameresults =3D mssql_fetch_array($results)){
$Name =3D $namereults(['Name']);
echo "$Name
";
}
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:ajwei@indiana.edu]
Sent: Wednesday, June 18, 2008 10:45 AM
To: php-windows@lists.php.net
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=3D"MSSQL";
$username=3D"user";
$password=3D"password";
$sqlconnect=3Dodbc_connect($dsn,$username,$password);
$sqlquery=3D"SELECT title FROM books";
$process=3Dodbc_exec($sqlconnect, $sqlquery);
while(odbc_fetch_row($process)){
$Name =3D odbc_result($process,"Name");
echo "$Name
"; }
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.
==================== =====3D=
==================== =====3D=
====
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei@indiana.edu
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--=20
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
RE: MSSQL and ODBC Connections with PHP on Windows
am 19.06.2008 13:08:32 von ajwei
SGksIEVyaWM6DQoNCiAgIEkgdXNlIGJvdGgsIGFsdGhvdWdoIEkgZm91bmQg dGhhdCBJIGhhdmUg
b25seSBiZWVuIHVzaW5nIFdpbmRvd3MgQXV0aCB3aGVuIEkgbG9nIG9uLCBz aW5jZSBJIGhhdmUg
bm90IHlldCBmaWd1cmVkIG91dCBob3cgdG8gZ2V0IHRoZSAibXNzcWwgc2Vy dmVyIGF1dGgiIHRv
IHdvcmsu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