السلام عليكم ورحمه الله
ارجوا من حضراتكم المساعدة فى حل المشكلة التالية
اقوم على عمل تطبيق يقوم بجلب البيانات من قاعدة البيانات mysql على سيرفر استضافة مجانية من خلال صفحة php ولكن الكود لا يعمل
فى حين ان الكود يعمل على المحاكى اثناء التشغيل على الكمبيوتر ، فهل السبب فى الكود ام لان الاستضافة مجانية علما بان الاستضافة على الموقع التالى :
كود php للاتصال :
<?php
include 'db/db_connect.php';
$movieArray = array();
$response = array();
//Check for mandatory parameter id
if(isset($_GET['id'])){
$Id = $_GET['id'];
//Query to fetch movie details
$query = "SELECT sr_name, rating FROM showroom WHERE id=?";
if($stmt = $con->prepare($query)){
//Bind id parameter to the query
$stmt->bind_param("i",$Id);
$stmt->execute();
//Bind fetched result to variables $SrName, $genre, $year and $rating
$stmt->bind_result($SrName,$rating);
//Check for results
if($stmt->fetch()){
//Populate the movie array
$movieArray["id"] = $Id;
$movieArray["sr_name"] = $SrName;
$movieArray["rating"] = round($rating,1);
$response["success"] = 1;
$response["data"] = $movieArray;
}else{
//When movie is not found
$response["success"] = 0;
$response["message"] = "Movie not found";
}
$stmt->close();
}else{
//Whe some error occurs
$response["success"] = 0;
$response["message"] = mysqli_error($con);
}
}else{
//When the mandatory parameter id is missing
$response["success"] = 0;
$response["message"] = "missing parameter id";
}
//Display JSON response
echo json_encode($response);
?>
package com.alo.tyre.android;
import java.util.List;
import android.app.Dialog;
import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
public class GizaStore extends ListActivity implements FetchDataListener{
private Dialog dialog;
Button back;
TextView mob;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.showroom);
initView();
ListView list = getListView();
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String mob = ((Application)parent.getItemAtPosition(position)).getContact().toString();
// String mab = ((Application)parent.getItemAtPosition(position)).getLocation().toString();
Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+mob));
startActivity(callIntent);
/*
String mob = ((Application)parent.getItemAtPosition(position)).getContact().toString();
String phone = ((Application)parent.getItemAtPosition(position)).getContact();
// Toast.makeText(getApplicationContext(), data , Toast.LENGTH_LONG).show();
if(phone == mob){
Intent phoneIntent = new Intent(Intent.ACTION_CALL);
phoneIntent.setData(Uri.parse("tel:" + mob));
startActivity(phoneIntent);
*/
// }
}
});
//*********************************
back = (Button) findViewById(R.id.btnBack);
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
//***************************
}
//*******************************************************************
private void initView() {
// show progress dialog
dialog = ProgressDialog.show(this, "", "Loading...");
// String url = "http://10.0.2.2/home/app/log/apps.php";
String url = "http://arafa4.000webhostapp.com/apps.php";
FetchDataTask task = new FetchDataTask(this);
task.execute(url);
}
@Override
public void onFetchComplete(List<Application> data) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// create new adapter
ApplicationAdapter adapter = new ApplicationAdapter(this, data);
// set the adapter to list
setListAdapter(adapter);
}
/*
public void onItemClick(List<Application> dt, View view,int position, long idn) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// create new adapter
Dialog_Sh_Adapter adapter = new Dialog_Sh_Adapter(this, dt);
// set the adapter to list
setListAdapter(adapter);
}
*/
@Override
public void onFetchFailure(String msg) {
// dismiss the progress dialog
if(dialog != null) dialog.dismiss();
// show failure message
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
}
@Override
protected void onResume() {
super.onResume();
this.onCreate(null);
}
}