Friday 21 February 2020

Can someone help me why this doesn't work?

const jq = require('jquery'); const mysql = require('mysql'); const con = mysql.createConnection({ host: "localhost", user: "root", password: "password", database: "votesystem" }); $(document).ready(function() { $("#votes").click(function() { con.connect(function(err) { if (err) throw err; var select1 = $('#sel1').find(":selected").text(); var select2 = $('#sel2').find(":selected").text(); var sql = "INSERT INTO voters (votername, votercomment) VALUES (select1, select2)"; con.query(sql, function (err, result) { if (err) throw err; alert("Voted successfully!") }); }); }); }); When I click the button, nothing happens in the database and alert msg doesn't show up.If it's not possible, how should I tackle the problem?TIA.

Submitted February 22, 2020 at 05:14AM by DecentTaro

No comments:

Post a Comment