Run php scripts, and fetch data from php

115 views
Skip to first unread message

denonth

unread,
Dec 11, 2011, 12:25:39 PM12/11/11
to android-qt
Hi all!

First of all guys you did nice job with that update you made! Thumb up
for you!!

So back to my little problem, I have made php script that is
communicating to my oracle database and when I run it it really
connects to database and do some basic table.


I want to execute that script from QT, and ofc send some parameters so
I can made some query in php file. I was trying few examples to run
script with qnetwork classes but I think I'm doing something wrong. So
anyone has some little example of how to send one parameter to php and
execute php script. Just so I can do the rest of the code.
And I need one more thing, how to use for example Json format in QT to
display data (or you can suggest some better options).
My app connects to server, server gets data from oracle, in php I send
data in some format back to device and display it.

Any examples are good. Probbably a lot of you have done such apps so I
would appreciate some answers with little examples, you don't need to
bother with big codes. Just to see how to communicate back and forward
with app->server->oracle database and back

Thank you all,
Denonth

Adam Pigg

unread,
Dec 11, 2011, 1:25:45 PM12/11/11
to andro...@googlegroups.com
Use QNetworkRequest and QNetworkAccessManager

something i do...

to send to the server:
QUrl url("http://www.someserver.com/somepage.php");
url.addQueryItem("action", "uploadscore");
url.addQueryItem("gamername", gamerName);
    
QNetworkRequest request(url);
m_networkManager->get(request);

to get the reply:
void HiScores::replyFinished(QNetworkReply *reply)
{
    m_lastMessage = reply->readAll();
    emit(messageReceived());
}

Adam Pigg

unread,
Dec 11, 2011, 1:26:27 PM12/11/11
to andro...@googlegroups.com
And you can use QJson to interpret json formatted data...i use it in a google latitude app

Adam Pigg

unread,
Dec 11, 2011, 2:08:22 PM12/11/11
to denonth, andro...@googlegroups.com
my samples arnt for interfacing directly with tables and getting entire queries back, the way i work is to create an interface in php, with pre-defined functions that return small amounts of data...you probably dont want to return entire tables, although the theory is the same...your php will likely have to return the data in either a json or xml format

On Sun, Dec 11, 2011 at 6:51 PM, denonth <domagoj...@gmail.com> wrote:
Hi Adam,
I have tried your code but I can't make it work. Can you send me small
example of code.
Can you show me how to receive and use Qjson format?
And please for example I get from user that he want's to see all data
from table. So I save query into one variable and I want to send that
to php I do that how?
And can you tell me more of what is best approach to work with php and
database if you said you already done similar app.
Any help is appreciated, thank's in advance!

All best,
Domagoj

Reply all
Reply to author
Forward
0 new messages