If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > No Tuples available in result

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-14-11, 06:24
ManjunathKCS ManjunathKCS is offline
Registered User
 
Join Date: Mar 2011
Posts: 1
No Tuples available in result

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

Last edited by ManjunathKCS; 03-14-11 at 06:24. Reason: Updated
Reply With Quote
Reply

Tags
mysql, odbc, php

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On