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

Free Dummies Books
Continuous Engineering

Learn:

  • What continuous engineering is
  • How to continuously improve complex product designs
  • How to anticipate and respond to markets and clients
  • How to get the most out of your engineering resources

Get your free book now

Sponsored by IBM

Free Dummies Books
Service Virtualization

Learn to:

  • Define service virtualization
  • Select the most beneficial services to virtualize
  • Improve your traditional approach to testing
  • Deliver higher-quality software faster

Get your free book now

Sponsored by IBM