[unixODBC-support] Invalid object name 'table'., SQL state S0002 in SQLExecDirect

Miguel A. Velasco miguel.suscripcion at gmail.com
Mon Jun 29 15:34:39 BST 2009


Hi, thanks Gérard for your help but it doesn´t work for me. I´ve tried 
what you commented and I have the following error message in Apache logs:

[Mon Jun 29 16:20:10 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]Incorrect syntax near 
'MY_MICROSOFT_DOMAIN.OITM'., SQL state 37000 in SQLExecDirect in 
/var/www/html/mydomain.com/index.php on line 7
[Mon Jun 29 16:20:10 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 9

I´ve tried with my Active Directory Domain Name but it still doesn´t 
work. I really don´t knwo where I can find a domain name in Sql Server 
2005, do you?

Thanks again for your time and help.
Miguel Velasco

Gérard Maulino escribió:
> Hi Miguel,
> 
> Not sure if that helps but I had the same kind of error when querying some
> 'TableNames' instead of 'domainName.TableNames'.
> I had to add a kind of domain name in the queries.
> 
> May be try to find out if there are some domains defined in the MS SQLServer
> service. Then just add it in the queries (like 'yourdomain.OITM' instead of
> 'OITM')
> 
> Regards,
> 
> Gerard
> 
> -----Original Message-----
> From: unixodbc-support-bounces at mailman.unixodbc.org
> [mailto:unixodbc-support-bounces at mailman.unixodbc.org] On Behalf Of Miguel
> A. Velasco
> Sent: lundi 29 juin 2009 13:16
> To: unixodbc-support at mailman.unixodbc.org
> Subject: [unixODBC-support] Invalid object name 'table'.,SQL state S0002 in
> SQLExecDirect
> 
> 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
> 
> 
> _______________________________________________
> unixODBC-support mailing list
> unixODBC-support at mailman.unixodbc.org
> http://mailman.unixodbc.org/mailman/listinfo/unixodbc-support
> 
> 



More information about the unixODBC-support mailing list