Print HTML/PHP using WAMP on Lan - php

I have installed WAMP on Computer whose IP is 192.168.1.1 and Printer is connected to same Computer
using USB.
And have configured WAMP so that my Android Device can access Server (WAMP) through WiFi,
i.e. http://192.168.1.1/myproject/print.php
My Android device ip is 192.168.1.2
What i want is to print data which is fetched from DB using PHP file, through Android device directly.
Please help me solving this issue.

You could start by looking at the docs for printing
http://developer.android.com/training/printing/index.html
However you should at least attempt to create an application and post this code to Stackoverflow for better feedback

Related

My ionic app wont connect to a MYSQL database running on the phone but on the PC with localhost it will run

I made an ionic app with a connection to MYSQL using a PHP API which I put on another computer on Xampp, using it as a remote server in the same network, when I run it on the computer with ionic serve , it works fine but when I generate the APK, it wont connect to the BD, even tho Im on the same network, does someone knows any way around this?
this is how it looks on the desktop
and this is how it looks on the cellphone
What I would conclude is that it connects to the nodejs server ("ionic serve") to load the assets from there but it cannot load data from the php/mysql API.
How did you reach the conclusion that MySQL is the problem? I mean your frontend (angular) does connect directly to MySQL right?
Hint: check your settings within ionic when you call the API -- it should point NOT to localhost/127.0.0.1 but to your computer's network IP. Apache should also be "open" to connections from "outside":
see here: Accessing localhost (xampp) from another computer over LAN network - how to?
I had the same problem in the past, it is because when you run the application on your pc it is working on localhost, just like your backend. When you run your application on a mobile device, it does not have access to your pc using localhost to access the backend.
In this case you must set the IP that your pc has on your local network as the backend address and in this way your mobile application can access it

Offline Android connect to PHP localhost using only USB cable

I'm trying to get JSON data from a PHP file (Apache/XAMPP) in localhost to Android using only a USB cable. The Android device is offline. Is it possible? Someone suggested using okhttp3 but I can't figure out how to.
If not already tried, Try running the app from emulator first but with the IPv4 address from ipconfig(command promt).use the ipv4 address instead of "Localhost:8080" use "Localhost:" in your code.

Ionic on Mobile + MySQL Server + PHP (XAMPP) on PC

Hi I am currently learning Ionic Framework for hybrid mobile apps and I want to connect it to localhost server (XAMPP).
I am developing Ionic App on my PC through ionic start myApp blank and ionic serve.
I have a php file on my htdocs folder in XAMPP which serves as a server-side function to call/query in my MySQL database.
Well, it goes well in development saying that I am working Ionic App on my PC where XAMPP also installed.
But, when I try to ionic cordova build my Ionic App for debug deployment as APK file and install the APK on my Mobile device it is not working.
Well, I know the reason why.
because of the link in my codes: var link = 'http://localhost/api.php';
My questions:
How can I access the PHP file inside localhost server XAMPP
on my PC when my Ionic App is already APK and installed on my
Mobile Device?
Can I use my PC IPv4 address (saying that PC and Mobile are connected
on same WIFI) instead of localhost in var link?
I hope someone can give me a light on my dark room.
Thanks in Advance
I got a way on how to connect to my PC localhost web server.
First, I tried to connect to my WIFI IPv4 Address using the command ipconfig on cmd. And I tried to connect to it, then it was a success. I was able to connect my Mobile App to my PC Localhost web server (XAMPP). But the problem is, whenever the WIFI restarts, the WIFI IPv4 Address changes because of my WIFI DHCP(from what I read).
So, I came up with a another solution to that. I set my WIFI IPv4 address in my PC's Control Panel/Network and Internet/Network Connections and edit the WIFI IPv4 Address, instead of automatically assigned, I changed it to static. Whenever my WIFI device restarts, it does not change my PC WIFI IP address.
So, that's how my problem solved. But I think there will be a problem sooner when theres a same WIFI IPv4 address assigned to other connected device on the WIFI. But, it is okay for now. I am glad that I can access my MySQL database on XAMPP in my PC from my Mobile Device and able to query data.
Thanks. I hope this can solve the problem of other people who has similar problem of mine. Happy coding.

Connecting Android device to Apache server

I have created a database and trying to access it using php. I execute these scripts from my phone. Now the issue is that when I try to perform any operation on the DB from the real device (my MOBILE PHONE) it says "unfortunately Closed" but works fine from the virtual device.
URL for real android device:
[http:// 127.0.0.1:8888 //android_connect/get_product_details.php]
URL for the virtual device:
[http:// 10.0.2.2 /android_connect/get_product_details.php]
The 127.0.0.1 is a loopback address so the android device or any other computer will not able to connect to it. Get a webserver (there's a lot freely available to test PHP scripts) , drop all the files in there and you will be able to access it.
say.. http://somefreewebhost.com/android_connect/get_product_details.php
Alternatively...
If you are using a webserver like WAMP, you will have an option called "Put Online". Go to your command prompt and type "ipconfig" and note down that IP address and you can even use that (provided if you are not behind any firewall)

connect app to php server on localhost

how can i connect an android app (on my phone) to a php server (EasyPHP) that i am running on my machine (localhost). Are there any tutorials out there that document this.
I need to test the app on an actual phone not an emulator (because the emulator contains bugs for certain activities). Any help would be great!
If you connect on your Android with WiFi, you will be in the same network, then you can access PHP server via your machine's IP address.
Ys you connect to the php script...
Android allows you to sent data in GET and POST method..
I found a useful tutorials about this: Android phpMysql connection

Categories