Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Forum Updated on Feb 6th

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

    General and Desktop
    4
    10
    3387
    Loading More Posts
    • 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
      Vicky_V last edited by

      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 Reply Quote 0
      • jsulm
        jsulm Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • V
          Vicky_V @jsulm last edited by

          @jsulm Server is running on Remote side

          1 Reply Last reply Reply Quote 0
          • jsulm
            jsulm Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • V
              Vicky_V @jsulm last edited by

              @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 Reply Quote 0
              • jsulm
                jsulm Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • V
                  Vicky_V @jsulm last edited by

                  @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 Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by SGaist

                      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 Reply Quote 0
                      • sushant1727
                        sushant1727 last edited by

                        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 Reply Quote 0
                        • First post
                          Last post