php and CONNX under Linux

I have installed the CONNX Unix client on a Linux machine. The license server runs on the same machine and I am using unixODBC as the driver manager.

I have created the ODBC.INI and ODBCINST.INI files, started the license server, and successfully run isql using the DSN defined in ODBC.INI. I can retrieve data through the Adabas SQL Gateway using the cdd files I have moved to the Linux box, using the isql command.

However, when I try to access the file from a php page using odbc_connect, I get the following message:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC]You are not licensed for any databases., SQL state 08001 in SQLConnect in /usr/apache/htdocs/test2.php on line 15
couldn’t connect

php page is very simple:

ODBC Test <?php // connect to a DSN "TAMIS-ADA-DEV" with a user and password "TAMIS-DEV" $connect = odbc_connect("TAMIS-ADA-DEV", "TAMIS-DEV", "TAMIS-DEV") or die ("couldn't connect"); // query the users table for name and surname $query = "SELECT * FROM [dbo].[TLC_TAM_ENTITY] WHERE ISN_TLC_TAM_ENTITY < 10";

// perform the query
$result = odbc_exec($connect, $query);

// fetch the data from the database
while(odbc_fetch_row($result)){
$suid = odbc_result($result, 1);
$uid = odbc_result($result, 2);
$gid = odbc_result($result, 3);
$name = odbc_result($result, 4);
print(“$name|$suid|$uid|$gid\n”);
}
// close the connection
odbc_close($connect);
?>

The Web Server isn’t able to either -

  • read the CONNXREGISTRY variable or
  • read the CONNX Registry File.

On the LINUX machine -
o is there a location specific for environment variables to be defined so the web server can pick them up?
o does the web server account have permission to open the connxreg.db ?

I added a putenv to the php page,

putenv(“CONNXREGISTRY=/home/connx/connxreg.db”);

and the error changes to,

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC]Creation of Information Schema failed. CDD probably locked by another user., SQL state 08001 in SQLConnect in /usr/apache/htdocs/test2.php on line 15
couldn’t connect

I have no idea why the cdd file would be locked. Perhaps this is indicative of a different problem?

I have also chmod 777 both the directory where the cdd file is held and the cdd file itself. I still get the cdd locked message.

Anyone have any ideas?

In case anyone else has the same problem, CONNX have solved it!

Apparently, SQL Gateway writes some sort of small file, a schema or something like that, to the current directory. In my case this was the directory of my php page usr/apache/htdocs.

Apache was running under the daemon id and so this id needs write access to the “local directory”.

Hope this helps someone else. If anyone requires more details then feel free to contact me.

Andy.

Hello I have a similar problem with php and connx.

I am using unixODBC and I can retrieve data through the isql but when I try from a php program I get this error:

Warning: odbc_connect() [function.odbc-connect]: SQL error: [unixODBC]CreateInfoSchemas: Unable to connect to the CONNX Schema connection database., SQL state 08001 in SQLConnect in /desarrolloweb/pbancosdesar/sicon/conectaodbc.php on line 12

I tried to set the variable where is the connxregistryfile but nothing.

This is the programa I am trying to use:

Thanks for your help.

The program.

Henry

putenv(“CONNXREGISTRY=/sti/sag/connx/connx/connxreg.db”);

$odbc=“asistencianuevo”;

$conn=odbc_connect($odbc,‘apc01’,‘apc01’);
if (!$conn)
{
exit(“Connection Failed al odbc $odbc: ->” . $conn);
}
else
{
echo “Estoy conectado a $odbc…”;
//odbc_close($conn);
// echo "Me desconect
conectaodbc.txt (752 Bytes)

Please ensure that the application has READ/WRITE access tot he following:
o CDD
o current directory