Jump to content

Teradata connection with PHP


sunilvadranapu

Recommended Posts

Hi,

  did any one know how to connect to teradata from PHP with dsn less connection.

  I am getting error while trying with below code -

      ODBC error: [DataDirect][ODBC lib] Invalid string or buffer length

      ODBC error code: S1090

 

Code:

<?php

$con_string = "DRIVER={Teradata};DBCName=sunil; DATABASE=DBC;

 

if (!($this->connection_id = @odbc_connect( $con_string, ****, *****)) ){

        echo "Connection Failed");

}

else {

        echo "Connected to DB..."."\n";

}

 

?>

 

Can any one tell me whats the problem in this code.

 

thanks in advance

 

-sun

 

Link to comment
Share on other sites

  • 3 weeks later...

I am able to connect to Teradata using DSNless connection in windows but failing in Linux.

my code is


  function ConnectDB($host, $username, $password, $options="") {
$con_string = "DRIVER={Teradata};DBCName=" . $host ."; DATABASE=DBC; RunInQuietMode=Yes";
        if (!($this->connection_id = @odbc_connect($con_string,$username,$password)) ){
                $this->report_error("\nConnection Failed.....\n");
                  exit;
        }
        else {
                echo "\nConnected to ". $host. " DB..."."\n";
                  return $this->connection_id;
        }

        }//end of connectDB
[/Code]

 

The above code is working fine in Windows but resulting below errors in Linux

  ODBC error: [DataDirect][ODBC lib] Invalid string or buffer length

  ODBC error code: S1090

 

I think we can use odbc_connect() function for both DSN and DSNless connections. As per my knowledge,

odbc_connect() when used with DSN connection, calls SQLConnect(). But when used with DSNless connection calls SQLDriverConnect(). 

 

But when i checked my driverTrace, i observed that odbc_connect in linux calling SQLConnect() eventhough i am passing DSNless connection string.

 

could any one help in this regard.

 

thanks in advance

 

-sunil

Link to comment
Share on other sites

You don't have the teradata driver in linux, hence your issue.

There's nothing wrong with the ODBC call, just the string you're giving it. The linux driver for teradata doesn't exist.

 

Hence to correct your problem, install the teradata linux driver on the machine in question.

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 months later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.