1

I Working on Qt where i need to insert data generated from Qt into the mysql database through php script. I am developing one Android Application so I have found this way only to insert data into mysql server through php? I look forward for yours replies I'll be very thankful if help me out of this problem. more than 2 weeks i am trying to this.

Thanks!!

  • Well, you can always access PHP-sites using QNetworkManager, but have you considered on directly using the QtSql-Library? – Felix Nov 23 '15 at 21:38
  • Yes initially i have used with QSQL-LIbrary it gets error as follows: "Driver not loaded" Because Android doesn't support MYSQL and it supports only SQLITE SQLITE is not server based – Vivek Vishwakarma Nov 24 '15 at 05:55

2 Answers2

1

There are a few ways you can do this. If your Android app is only for you or a small group of people, you could connect directly to the MySQL database on your server using the QSql library.

However, that won't scale well and it isn't best practice to have direct database connection on an open network.

An alternative way is to use HTTP Post commands to your server where a php script will be able to unpack the information contained within the POST data. Once the PHP script has unpacked the information it can then insert it into the MySQL database on the same server or a different one.

It would be advisable to encrypt the data before sending from your app and decrypting the data in you php script, especially if commercially or personally sensitive data is being transferred.

The following stack overflow questions may help you with creating HTTP POSTs:

How can I create a HTTP POST request with Qt 4.6.1?

Qt Simple Post Request

Community
  • 1
  • 1
Michael Vincent
  • 1,620
  • 1
  • 20
  • 46
0

Most of the people do struggle in qt c++ programming while to go error "Driver not loaded". To fix this problem just install mysql and go to programme files and open msql folder. then go to bin and copy a file written "libmySQL.dll" and paste it in the bin of qt bin folder, the problem will be solved if you still got a problem i will sent you my Qt creator 5.7Tutorial. Thankx, I hope this will work for you