Use MacBook as Mysql Local Server - php

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.

Related

How to connect a web app in a pc with a database on another pc using php mysql XAMPP

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.

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

react and php and mobile

I am using react for my frontend, PHP and MySQL for the backend. React is running on localhost, port 3000 and xampp server is in localhost, port 80.
I am getting data from MySQL to php parse to json format. For the frontend, I used axios API to call the data.
While I am in browser, I am able to see the data, but when I access the same page from mobile, I can see only the tables not the json data.
Its probably because you are running your application locally, and wont be able to access localhost on your mobile (because as the word itself suggests its LOCALhost). If your mobile is on the same network as your desktop you can access the site from your computers local ip address.
I guess your front-end is configured to use http://localhost as the back-end url ? Which means that when running on your phone, its using the phone host as the back-end url :)
Try setting the back-end url to http://192.168.1.99 on the front-end.
Change API url to:
http://192.168.1.99/assets/data.php
You used localhost/assets/data.php, but your xampp was installed on your PC, not on your mobile, so your mobile can't access to this.
Hi to test it on mobile you could also used Remote Device from chrome developer tools.
For details you can check on this Link
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews

How to access PHP, MYSQL localhost database on android actual device

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.

create local server on android

I want a develop a web application with php, and I want a run my apps with a android device. But my device will not be connected to internet, so I must create a local server on the device to run my php code. Is it possible? And if it's possible how?
Based on this page, developing Web Server for mobile devices is still on the research phase. Most probably you would need to use some kind of simulator for Android and develop your App on powerful desktop PC.
EDIT: Looks like such a server exists for Android.
Please use KSWEB.apk. This app supports PHP, SQL, html, csc, but it requires 3 android devices. The first serves as router, the 2nd device is a local server and the 3rd devices is a monitor.
I'm not sure about your need to have a web server running on your phone, but if you have a wireless router and your phone can connect to it, can you not install an Apache server with PHP support on your development PC and access it via your phone's wireless connection?

Categories