>>there is no data from database written.
Read you program again. Where does it even attempt to write anything to the text file? Where does your program call readFromDB() to get the row from the table? You program consists of two functions, one function that just opens a file then immediately closes it. And a second function that opens the database and executes a query -- it just ignores the result set. Nowhere does your program put those two functions together. You need to do something like this
OPEN THE TEXT FILE FOR WRITE
OPEN THE DATABASE
QUERY THE DATABASE
CALL mysql_field_count() TO SEE IF THE QUERY RETURNED A RESULT SET
FOR EACH RESULTSET ROW (one of the mysql_fetch??? functions)
WRITE RESULT ROW TO TEXT FILE
CLOSE THE DATABASE
CLOSE THE TEXT FILE
You need to be familiar with the mysql docs if you want to write a program that queries a mysql database.
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343