php - Call to undefined function odbc_connect() message while connecting SAP Hana database -
i used odbc_connect()
in php page connect hana database. works fine when run locally. upload same php page server , getting error:
fatal error: call undefined function odbc_connect()
the code:
$connect = odbc_connect("team6datasource", "team6", "password1", sql_cur_use_odbc);
team6datasource = datasource name.
ip address = 54.217.234.218
can 1 please me? thanks
i go through in google this instruction helpful you.
- download sql server odbc driver php client
platform. (registration required.) if sql server odbc driver not available platform, check list of
odbc-odbc bridge client platforms. odbc-odbc bridge an
alternative sql server solution easysoft, can download site. - install , license sql server odbc driver on machine php installed. installation instructions, see odbc driver documentation. refer documentation see environment variables need set
(ld_library_path, libpath, ld_run_path, shlib_path depending on driver, platform , linker).
create odbc data source in
/etc/odbc.ini
connectssql server database
want access php. example, sql server odbc data source connects sql server express instance serves northwind database:- use isql test new data source. example:
cd /usr/local/easysoft/unixodbc/bin
./isql -v mssql-php
- use isql test new data source. example:
[mssql-php] driver = easysoft odbc-sql server server = my_machine\sqlexpress user = my_domain\my_user password = my_password
please copy , paste script , execute
<? /* php mssql example replace data_source_name name of data source. replace database_username , database_password sql server database username , password. */ $data_source='data_source_name'; $user='database_username'; $password='database_password'; // connect data source , handle connection. $conn=odbc_connect($data_source,$user,$password); if (!$conn){ if (phpversion() < '4.0'){ exit("connection failed: . $php_errormsg" ); } else{ exit("connection failed:" . odbc_errormsg() ); } } // query generates result set 1 record in it. $sql="select 1 test_col"; # execute statement. $rs=odbc_exec($conn,$sql); // fetch , display result set value. if (!$rs){ exit("error in sql"); } while (odbc_fetch_row($rs)){ $col1=odbc_result($rs, "test_col"); echo "$col1\n"; } // disconnect database database handle. odbc_close($conn); ?>
- replace
data_source_name, database_username , database_password
sql server odbc data source, login name , password. to run script under apache, save file below apache web server’s document root directory
. example, /var/www/apache2-default/php-mssql-connection.phtml. view file in web browser:
http://localhost/php-mssql-connection.phtml
- if web browser not running on same machine web server, replace localhost web server’s host name or ip address.
to run script command line, save file.
for example, /tmp/php-mssql-connection.php. run $ php /tmp/php-mssql-connection.php.
Comments
Post a Comment