0

I want to store data into mysql table using JavaScript. But, I don't want to use php. Is it possible?

6
  • See here: stackoverflow.com/questions/3020751/… Commented May 3, 2017 at 6:13
  • you might want to use node js that might help you interact with the server using java script Commented May 3, 2017 at 6:16
  • You can use any language you want on the server side. Commented May 3, 2017 at 6:19
  • Just curious: why not php? Commented May 3, 2017 at 7:11
  • Possible duplicate of Can JavaScript connect with MySQL? Commented May 3, 2017 at 8:24

3 Answers 3

1

Javascript is a client-side language, so it runs on the clients browser. If you still want to insert into mysql using javascript then you could use something like node.js which would run on the server-side.

For instance this is how an insert using node.js would look like:

var post  = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function(err, result) {
    // check result or error!
});
Sign up to request clarification or add additional context in comments.

3 Comments

actually I want to use it only for like counter, I mean i want to increment in like counter. I hope you might understand what I want to do .. further is it a good approach to use node.js for only like counter ?
@Jahangir what is it that you would like to count?
as I said above. I want to count "likes" of a video on my webpage.
0

You may need to consider Node Js for such job. Check this

1 Comment

This is not the answer. It should be a comment
0

Jahangir jan, It's not possible to use client side Javascript to store something into the MySQL. But it's possible to use server side Javascript to do it.

1 Comment

Yes nodejs is a server side Javascript language so you can communicate with database as well.

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.