Download unixodbc.x.xx.rpm file and configure in the unix machine,Once after configuring two files will get generated on /etc/ path odbc.ini and odncinst.ini files
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 odbcinst.ini file [MySQL] Description = ODBC for MySQL Driver = /usr/lib/libmyodbc5.so Setup = /usr/lib/libodbcmyS.so FileUsage = 1 UsageCount = 3Once after configuring above and give below command to ensure configuration is correct or not
isql -v DSNNameBelow is the PHP code to connect
$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);
Wednesday, 18 May 2011
Steps to configure PHP-MYSQL using ODBC driver on Linux OS
Labels:
PHP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment