RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows
| From: | Zephaniah ha Levi | Date: | Wed, 18 Jun 2008 14:53:16 +0000 |
| Subject: | RE: [PHP-WIN] MSSQL and ODBC Connections with PHP on Windows | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-28937@lists.php.net to get a copy of this 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: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<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
ajwei@indiana.edu
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php