Hi folks,
I followed the direction for running ODBC on Linux machine with iODBC. You can take a look at this website: http://www.iodbc.org/odbc-phpHOWTO.html
I installed libiodbc-3.0.5.tar.gz and extract it.
This is the code that I want to try:
<?php
putenv("LD_LIBRARY_PATH=/usr/local/src/odbcsdk/lib");
putenv("ODBCINSTINI=/path/to/odbcinst.ini");
putenv("ODBCINI=/path/to/odbc.ini");
$dsn="DSN=DSN_NAME";
$user="username";
$password="password";
$sql="SELECT * FROM table";
if ($conn_id=odbc_connect("$dsn","","")){
echo "connected to DSN: $dsn";
if($result=odbc_do($conn_id, $sql)) {
echo "executing '$sql'";
echo "Results: ";
odbc_result_all($result);
echo "freeing result";
odbc_free_result($result);
}else{
echo "can not execute '$sql' ";
}
echo "closing connection $conn_id";
odbc_close($conn_id);
}else{
echo "can not connect to DSN: $dsn ";
}
?>
But I got this error message :
Fatal error: Call to undefined function: odbc_connect() in /var/www/html/test1.php on line 12
Anyone has the solution? I tried to write other codes but gave me the same error that undefined function for odbc_connect().
Is that because I didn't install the mysql?
Thank you.
Best Regards,
SanGtIm