0

I have an HTML file that is loaded as a WebView in my Qt MainWindow and the file is located on the localhost XAMPP folder. The file basically takes two date and time intervals from the user and when the user clicks the Fetch queries button, map displays the total amount of queries -fetched from the MySQL Database on XAMPP- as a heatmap. However, trying to run this HTML file from the Qt -clicking the Fetch queries button of the HTML window- gives me Ajax POST error and I can't access the database from Qt, while the localhost copy can. I also tried to POST to the PHP file that fetches queries by using NetworkAccessManager but I got an "Unknown Error" as a reply. Is there a particular way of fixing this? The HTML-jQuery code and The NetworkAccessManager post codes are below:

HTML-jQuery Part:

<form id="ajaxForm" action="index.php" method="post">

Start <input type="text" name = "date1" id = "datepicker" value = "2011-07-13" style = "width:70px">
<input type="text" name = "time1" id = "timepicker1" value = "00:00" style = "width:40px"> 
--
End <input type="text" name = "date2" id = "datepicker2" value = "2011-07-13" style = "width:70px">
<input type="text" name = "time2" id = "timepicker2" value = "00:01" style = "width:40px">



<select name = "freq">
  <option value = "all" selected = "true">all</option>
  <option value = "hourly">hourly</option>
  <option value = "daily">daily</option>
  <option value = "weekly">weekly</option>
  <option value = "monthly">monthly</option>
</select>

data between 
    <input type="text" id="time" style="border:0; color:#f6931f; font-weight:bold;" />

    <input type="submit" name="fetch" value="Fetch">


</form>

And the NetworkAccessManager part I used to test my PHP file for replies:

QNetworkAccessManager* mNetworkManager = new QNetworkAccessManager(this);
QObject::connect(mNetworkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(onNetworkReply(QNetworkReply*)));
connect(mNetworkManager, SIGNAL(finished(QNetworkReply*)),
        this, SLOT(replyFinished(QNetworkReply*)));
QUrl url = "http://localhost/heatQuery.php";


QUrl params;
params.addQueryItem("date1","2011-07-13");
params.addQueryItem("time1","00:00");
params.addQueryItem("date2","2011-07-13");
params.addQueryItem("time2","13:00");
params.addQueryItem("freq","hourly");


QByteArray data;
data.append(params.toString());
data.remove(0,1);

QNetworkRequest request;
request.setUrl(url);
request.setHeader(QNetworkRequest::ContentTypeHeader,
QVariant("application/x-www-form-urlencoded"));
mNetworkManager->post(request, data);


void MainWindow::replyFinished(QNetworkReply *reply){
//Use the reply as you wish
QString text(reply->errorString());
std::cout<<"REPLY IS" << text.toStdString() << std::endl;

}
bremmS
  • 277
  • 1
  • 6
  • 13

1 Answers1

1

As the localhost copy is accessing database successfully,Change the permission of your database and then run.

For changing database permission to full execute this[Assuming you are using linux] command.

 chmod 777 database_name
ScarCode
  • 3,074
  • 3
  • 19
  • 32
  • thanks, actually I use Windows 7 but using phpMyAdmin settings and granting execute permissions seemed to work but I still get some post errors and repeatedly clicking the Fetch button then does the job. Any ideas on what may be causing this? – bremmS May 18 '12 at 19:24