my android project based on php, mysql database, when i run in my actual device which is google nexus7 the application running without any error messages, but im not able to access the database files which in my pc localhost wamp server.
Local host means, by definition, you can only access it from that machine. That's why it is local.
Access the server via a local network or build an actual website.
Related
I have a web app in php mysql programmed with xampp server.
I need to have the web server with the app files in one pc on xammp and connect it to a mysql database on another pc using xampp also I imagine on phpmyadmin as usual.
I don't know how to redirect the database, as in one pc you just put the dB name in the queries but I don't know how to do it if the database is on another pc.
I couldn't find any info online, I already can access my xampp server through ip address on another devices but with the web server and the dB server on the same pc.
I need to have the web app files in one pc and the database in another, using xampp in both pc. So I can connect other devices as clients and use the web app normally.
Please help:( it is for a project :(
Edit:
I am beginner, so I really would like a detailed explanation with examples please so I can replicate it.
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
I have a MacBook and I am currently working on a web-app for our school. I am using PHP, MySQL, and Apache, all provided through the XAMMP stack.
When testing the website via localhost it works fine. Now, some of my teachers wanted to try out the web-app via their phones. Can I configure my MacBook to work like some sort of a 'local server' (e.g. probably through the internal network) to which other devices on the same internal network can connect via their phone browsers?
Is this possible?
You need to understand in using a Website, the client itself doesn't need to contact the database server. The web server is the one who communicate with database server and send/serve html pages to the client.
Phpmyadmin is a website not a database itself. So you simply need to allow access to your web server,you can use your laptop as web server. Test directly using your laptop as a web server, open the website instead using localhost change it to your laptop ip address. If it's not working then tell us the error so we can help you from there.
I have developed an android app that connect mysql database using php. when making https request to scripts php from other computers located on the same local network no problem, but when trying to request the same scripts from my android phone it gives tcp errors.
There is however a far better solution. You can access your host machine with the IP address "10.0.2.2".
This has been designed in this way by the Android team. So your webserver can perfectly run at localhost and from your Android app you can access it via http://10.0.2.2:8080.
What error do you get? If it's a forbidden error then it could be your httpd config file blocking your android. Can you tell from the error whether the problem is in your android application or a network connectivity error?
I have a PHP/MySQL application running with WAMP on a local server. This application contains sensitive and confidential data that can only be accessed from devices on the network in the office.
However, this application generates reports that clients should be able to access from the web from an entirely separate application running on a LAMP stack.
Currently, I have the reports transferring via SFTP from the local server to the web based server.
My question is, how can I update the remote database from the local application securely, and so that the MySQL db can only be modified by the localhost of the remote application and the server running the local application?
I'm thinking about creating some kind of API that only accepts data from the IP of the local app, but I do not know the best practices for this, nor do I know how to start going about it.
MySQL provides a USER > FROM HOST > PER DATABASE > PER TABLE > PER COLUMN grant system.
Meaning that you can specify which user can connect from which host to which database,... Make usage of the FROM HOST feature.