[unixODBC-support] Invalid object name 'table'., SQL state S0002 in SQLExecDirect
Miguel A. Velasco
miguel.suscripcion at gmail.com
Mon Jun 29 12:15:58 BST 2009
Hello all, I´m trying to config my linux LAMP webserver running on
Centos 5.3 to connect to a Microsoft Sql Server 2005 database running on
a different server with Windows 2003 Server.
The idea is to generete web reports written on PHP from SAP Database on
W2003 Server but I have a problem I´m not able to solve by myself.
I followed the instructions from
http://members.cox.net/midian/howto/phpMSSQL.htm and I have the
following configuration:
Packets installed:
rpm -qa | grep -i freetds
freetds-devel-0.64-11.el5.centos
freetds-doc-0.64-11.el5.centos
freetds-0.64-11.el5.centos
rpm -qa | grep -i unixodbc
unixODBC-2.2.11-7.1
unixODBC-devel-2.2.11-7.1
rpm -qa | grep -i php
php-5.1.6-23.2.el5_3
php-ldap-5.1.6-23.2.el5_3
php-mcrypt-5.1.6-15.el5.centos.1
php-devel-5.1.6-23.2.el5_3
php-pdo-5.1.6-23.2.el5_3
php-xml-5.1.6-23.2.el5_3
php-mbstring-5.1.6-23.2.el5_3
php-mysql-5.1.6-23.2.el5_3
phpmyadmin-2.11.9.5-1.el5.rf
php-odbc-5.1.6-23.2.el5_3
php-cli-5.1.6-23.2.el5_3
php-common-5.1.6-23.2.el5_3
php-gd-5.1.6-23.2.el5_3
Config Files:
cat /etc/odbc.ini
[MSSQL_SAFE01]
Description = Base de datos SAFE_01 (SAP)
Driver = FreeTDS
Trace = No
Server = 10.10.80.10
UID = sa
PWD = mypassword
Port = 1433
cat /etc/php.d/odbc.ini
; Enable odbc extension module
extension=odbc.so
My index.php in the webserver is:
$cat index.php
<?php
// definicion de la cadena de conexion al DSN "MSSQL_SAFE01" con usuario
//"sa" y password "mypassword"
$connect = odbc_connect('MSSQL_SAFE01', 'sa', 'mypassword') or die
("Could not connect to server");
// definimos la query para sacar datos de la base de datos SAFE_01 en
//Galileo
$query = "SELECT * FROM OITM";
// realizamos la conexion y ejecutamos la query
$result = odbc_exec($connect, $query);
// obtenemos los datos de la base de datos SAFE_01
while(odbc_fetch_row($result)) {
$field1 = odbc_result($result, 1);
$field2 = odbc_result($result, "field2");
print("$field1 : $field2\n");
}
// close the connection
odbc_close($connect);
?>
When I access to the url I see nothing and in the Apache Error logs
that´s what I see:
[Mon Jun 29 12:20:46 2009] [error] [client 10.10.80.81] PHP Warning:
odbc_exec() [<a href='function.odbc-exec'>function.odbc-exec</a>]: SQL
error: [unixODBC][FreeTDS][SQL Server]Invalid object name 'OITM'., SQL
state S0002 in SQLExecDirect in /var/www/html/mydomain.com/index.php on
line 8
[Mon Jun 29 12:20:46 2009] [error] [client 10.10.80.81] PHP Warning:
odbc_fetch_row(): supplied argument is not a valid ODBC result resource
in /var/www/html/mydomain.com/index.php on line 10
I think I´m connecting right to the database but I am not able to
execute the query, but I don´t know why ... The 'OITM' table really
exists on my database!
I would very grateful who can help me.
Best regards,
Miguel Velasco
More information about the unixODBC-support
mailing list