1

As the question says, is it possible to interact with a MySQL database created with XAMPP (so, using PhpMyAdmin) without using PHP, but only Javascript/JQuery?

This is a merely theoretical question, I don't want to know how to (but if you know it, I want discard your help).

With this, I don't mean using Ajax to send my request to a .php page that will then interact with the database, but directly interacting without passing through PHP.

Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
tenik
  • 250
  • 1
  • 4
  • 20
  • 1
    NO. Javascript/jQuery execute in the browser. You need to have some connector to connect to your database. – Dipen Shah Sep 04 '15 at 16:44
  • 7
    possible duplicate of [Is it possible to access a MySQL database straight from Javascript](http://stackoverflow.com/questions/9767614/is-it-possible-to-access-a-mysql-database-straight-from-javascript) – Richard Christensen Sep 04 '15 at 16:49
  • 1
    The statement from @DipenShah is a bit bald, we do have node.js right? You need to have a server-side implementation that interacts with the database and other possible servers which your app might use. – DaGhostman Dimitrov Sep 05 '15 at 02:13

3 Answers3

4

In terms of a PHP application, it's not possible to interact with MySQL through JavaScript because JavaScript is executed client side i.e in the browser, it doesn't have access to anything on the server it is being served from.

However, with nodejs - a JavaScript runtime built on Chrome's V8 JavaScript engine - you can write a complete JavaScript server side application without having to touch PHP. There's a node-mysql module which means you can interact with a MySQL database with JavaScript code.

Several web application frameworks exist to help you get something up and running like Express, which saves you the burden of having to write up things like routing logic.

Andy
  • 4,901
  • 5
  • 35
  • 57
1

No you can't interact with MySQL through JavaScript or JQuery. You could use JavaScript and JQuery through your PHP pages if that would be a functionality you'd be interested in. You could also use another language compatible with MySQL. Otherwise interacting with MySQL straight through JavaScript/JQuery won't work.

user5166162
  • 156
  • 2
  • 11
-1

You can do openDatabase() Make an SQL file, db.sql, and in a javscript file, type this: openDatabase(db.sql, '1.0', 'My First Database', 65535) More on this here: http://html5doctor.com/introducing-web-sql-databases/.

This makes an SQLite connection. I recommend it as it doesn't use PHP, but if you really really want to use MySQL(Again, I recommend using this SQLite method) you have to use PHP or some sort of server scripting language.

Learn SQLite: https://www.tutorialspoint.com/sqlite/index.htm

This works on:

XAMPP

repl.it

well, basically anything.

Superman123
  • 11
  • 1
  • 3