2

I am trying to make an app using phone gap that makes users login in. I know how to connect to a mysql database using php but I have no clue on how to connect to it using ajax. I hope someone could show how its done or if there is another way to connect to a mysql database in phonegap.

Thank You

2 Answers 2

4

You can't directly connect to MySQL database from client side.. This is not exactly correct (but I've heard some people doing similar with MongoDB).

Anyway, right approach for this is:

  1. You have to have a server side code (web service) with methods that actually connect to database, perform CRUD operations. This would be you application API.
  2. In client you use that API. If you are on Javascrip, using of jQuery is best.
Sign up to request clarification or add additional context in comments.

1 Comment

wow, that was the answer i was looking for, thank you so much
2

This is not specific to Android.

Anyway, last time I checked, it wasn't possible to connect directly to MySQL via AJAX.

What you need is a back-end (in php, for example) that accepts connection via AJAX and then connects to MySql, processes the data and gives back the results via JSON, XML, plain text or whatever format you prefer.

1 Comment

Thanks for answering The problem with that is phonegap can not run php , so how can i back-end php code ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.