Re: PHP -> MSSQL connects, but can't query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hmm, replace the line where you select the DB with:

$dbconnect = mssql_select_db("Northwind") or
die(mssql_get_last_message());

(All on one line incase the email wraps it.)


On Fri, 2004-03-12 at 08:35, Jason Morrill wrote:
> I've got a very simple PHP script for testing my MS SQL Server
> connection. I've installed FreeTDS and I can connect and query the
> database with TSQL.
> 
> With PHP I can connect and disconnect properly but I can't query or
> attach to different databases. Here is my sample PHP followed by what
> the web server throws back at me:
> 
> sql-test.php
> ------------
> 
> <html>
> <body bgcolor=white>
> <?php
> $dbproc = mssql_connect("roger","sa","admin");
> #$dbproc = sybase_connect("roger","sa","admin");
> if (! $dbproc) {
>         print "Can't connect to server";
>         return;
> }
> print "Connected to server.";
> 
> $dbconnect = mssql_select_db("Northwind");
> if (! $dbconnect) {
>         print "Can't connect to Northwind";
>         return;
> }
> print "Connected to database";
> 
> #$res = sybase_query("select * from test",$dbproc);
> #if (! $res) {
> #       return;
> #}
> #while ($arr = sybase_fetch_array($res)) {
> #       print $arr["i"] . " " . $arr["v"] . "<br>\n";
> #}
> 
> if (! mssql_close($dbproc)) {
>         print "Can't close server connection";
>         return;
> }
> print "Connection closed.";
> ?>
> </body>
> </html>
> 
> ================================================
> 
> Output in browser when referencing the sql-test.php file:
> ---------------------------------------------------------
> 
> Connected to server.
> Warning: Sybase: Server message: Line 1: Incorrect syntax near 'e'.
> (severity 15, procedure N/A) in /home/www/sql-test.php on line 12
> Can't connect to Northwind
> 
> ================================================
> 
> Can anyone help me figure this one out?!
> 
> Thanks!
>  Jason Morrill
>  IT Manager
>  Child & Family Agency SE Connecticut 
-- 

Adam Voigt
adam@xxxxxxxxxxxxx

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux