Hi,
I have PHP sample code which will fetch the data from the MYSQL database through ODBC driver on Linux(CentOS) machine.
I have created DSN and same able to connect through following command isql -v But when i try to same DSN through PHP code i am getting "No tuples available at this result index" due to which unable to read the data from database through PHP APACHE configuration.
If anyone provides the solution,It will more helpful for me to proceed further.
Below are my sample code and other details,Please correct if anything wrong on below configuration details-
Below is sample PHP code:
<?php
$conn = odbc_connect("DSN", "username", "password");
$sql = 'select * from tablename';
$rs = odbc_exec($conn,$sql);
echo "User Name";
while(odbc_fetch_row($rs)) {
$user = odbc_result($rs,"fieldname");
echo "$user";
}
odbc_close($conn);
?>
Below is odbc.ini file:
[DSN]
Description = MySQL ODBC Database
DRIVER = MySQL
TraceFile = /tmp/odbcerr.log
SERVER = 127.0.0.1
PORT = 3306
USER = username
PASSWORD = password
DATABASE = database
OPTION = 3
SOCKET = /var/lib/mysql/mysql.sock
Below is odbcinst.ini file:
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc5.so
Setup = /usr/lib/libodbcmyS.so
FileUsage = 1
UsageCount = 3