Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How To Insert Data which is generated From Qt App into MySQL Database through PHP?
Forum Updated to NodeBB v4.3 + New Features

How To Insert Data which is generated From Qt App into MySQL Database through PHP?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 4 Posters 4.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vicky_V
    wrote on last edited by
    #1

    Hello All,

    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!!

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Do I understand you correctly: you want to store data in a MySQL server which is running on a remote server? Or do you have a local MySQL server (running on the same machine/device as your Qt App)?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      V 1 Reply Last reply
      0
      • jsulmJ jsulm

        Do I understand you correctly: you want to store data in a MySQL server which is running on a remote server? Or do you have a local MySQL server (running on the same machine/device as your Qt App)?

        V Offline
        V Offline
        Vicky_V
        wrote on last edited by
        #3

        @jsulm Server is running on Remote side

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Does the server allow direct connection to the MySQL server?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          V 1 Reply Last reply
          0
          • jsulmJ jsulm

            Does the server allow direct connection to the MySQL server?

            V Offline
            V Offline
            Vicky_V
            wrote on last edited by
            #5

            @jsulm In Qt is not allowed that is why i am using php script. I am using WAMP Server.
            I have done all thing ...... i mean to say that...... I have PHP Script which having two variables they stores $Name and $City field in the MySQL database.
            But the doubt is that how can i store my qt application values to php variables ($Name and $city) so then php will insert into database.

            1 Reply Last reply
            0
            • jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What is not allowed in Qt?
              You can connect to a SQL database and use it.
              See here: http://doc.qt.io/qt-5/sql-programming.html
              http://doc.qt.io/qt-5/qsqldatabase.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              V 1 Reply Last reply
              0
              • jsulmJ jsulm

                What is not allowed in Qt?
                You can connect to a SQL database and use it.
                See here: http://doc.qt.io/qt-5/sql-programming.html
                http://doc.qt.io/qt-5/qsqldatabase.html

                V Offline
                V Offline
                Vicky_V
                wrote on last edited by
                #7

                @jsulm I am developing one android application in Qt.
                Android application does not allow to interface with MySQL Server. It show error like "MYSQL Driver not loaded"
                So I have searched a lot in google so there is only way to do this by php script
                DO you know how to insert data from qt app in mysql through php script?

                or else if you another way to insert data into mysql in android please let me know.

                1 Reply Last reply
                0
                • jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  It depends. Does the server provide any kind of web interface to upload data? On the server you can have a PHP, Python, Java or what ever based web application running, which accepts for example HTTP POST requests to upload data, which it then stores in the SQL database. How exactly you upload the data depends on your server.
                  You can start here: http://doc.qt.io/qt-5/qnetworkaccessmanager.html

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by SGaist
                    #9

                    Hi,

                    You can find guides that shows how to compile MariaDB client libraries for Android and use them to build the MySQL driver.

                    However it's not recommended to access a database server directly through internet so going through the web service route is a good plan.

                    You can use PHP Slim to build the web service.

                    Hope it helps

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • sushant1727S Offline
                      sushant1727S Offline
                      sushant1727
                      wrote on last edited by
                      #10

                      I'm new to QT and my first project was to do something similar you posted here where I've to add data in MySql database which is accessed by PHP file. What I did is I hosted my php file and MySql database on free php server from where I got the host ip address, database name, password.
                      In QT I used following to achieve the task of connecting PHP file and doing RESTfull CRUD operations using QT Visual Interface.
                      #include "mainwindow.h"
                      #include "insertdialog.h"
                      #include "updatedialog.h"
                      #include "deletedialog.h"
                      #include <QCoreApplication>
                      #include <QApplication>
                      #include <QHeaderView>
                      #include <QUrl>
                      #include <QNetworkRequest>
                      #include <QNetworkReply>
                      #include <QJsonDocument>
                      #include <QJsonObject>
                      #include <QJsonArray>
                      #include <QMessageBox>.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved