php script - mssql problem; could you help?

 in

[Tue Mar 04 14:10:00 2008] [error] [client 132.64.4.16] PHP Warning: odbc_exec() [function.odbc-exec]: SQL error: [unixODBC][FreeTDS][SQL Server]Invalid object name 'DeviceView'., SQL state S0002 in SQLExecDirect in /srv/www/htdocs/hu/Proj1/ttb.php on line 7
[Tue Mar 04 14:10:00 2008] [error] [client 132.64.4.16] PHP Warning: odbc_fetch_row(): supplied argument is not a valid ODBC result resource in /srv/www/htdocs/hu/Proj1/ttb.php on line 8
[Tue Mar 04 14:10:00 2008] [error] [client 132.64.4.16] PHP Warning: odbc_free_result(): supplied argument is not a valid ODBC result resource in /srv/www/htdocs/hu/Proj1/ttb.php on line 12

Source:

-- begin odbctest.php---
<?
// connect to DSN MSSQL with a user and password
$connect = odbc_connect("DSNNAME", "miki", "84139") or die ("couldn't connect");
odbc_exec($connect, "use SwitchCenterDB");
//$result = odbc_exec($connect, "SELECT * FROM DeviceView");
$result = odbc_exec($connect, "SELECT address, portalias FROM DeviceView");
while(odbc_fetch_row($result)){
print(odbc_result($result, "address") .
' ' . odbc_result($result, "portalias") . "\n");
}
odbc_free_result($result);
odbc_close($connect);
?>
--- end odbctest.php --

Hello Why dont you use/try

Anonymous's picture

Hello

Why dont you use/try the MySQLi commands. ODBC is very unreliable and predictable I have found and is more of a pain than it is worth.

Give that a try?
http://uk2.php.net/manual/en/book.mysqli.php

Geek Guide
The DevOps Toolbox

Tools and Technologies for Scale and Reliability
by Linux Journal Editor Bill Childers

Get your free copy today

Sponsored by IBM

Upcoming Webinar
8 Signs You're Beyond Cron

Scheduling Crontabs With an Enterprise Scheduler
11am CDT, April 29th
Moderated by Linux Journal Contributor Mike Diehl

Sign up now

Sponsored by Skybot