简体   繁体   中英

phpMyAdmin and node.js

I have created aa database called users in phpmyadmin and a table called personalinformation. I can connect to the database just fine using node.js javascript with this code:

var mysql = require('mysql');
var con = mysql.createConnection({
host: "localhost",
user: "user",
password: "****",
database: "users",

});

con.connect(function(err) {
if (err) throw err;
console.log("Connected!");

});

the table is already populated with some data. I now want to add extra data into the table. I used this code but its telling me that the table doesnt exist

var mysql = require('mysql');

var con = mysql.createConnection({
host: "localhost",
user: "user",
password: "password",
database: "users",


});

con.connect(function(err) {
if (err) throw err;
console.log("Connected!");

var sql = "INSERT INTO personalinformation (title, firstname, surname, mobile, email) VALUES ?";
var values = [
    ['Mr', 'John', 'Whelan', '0868337', 'john@gmail.com'],
    ['Mr', 'Peter', 'Lawless', '0885947', 'peter@gmail.com'],
    ['Ms', 'Amy', 'Apple', '08736855', 'amy@gmail.com']

];
con.query(sql, [values], function(err, result) {
    if (err) throw err;
    console.log("Number of records inserted: " + result.affectedRows);
});

});

the table structure is like this:

title     firstname      surname     mobile           email
 mr        john           whelan     0976577567      john@home.com

etc and there error message is Error: ER_NO_SUCH_TABLE: Table 'users.personalinformation' doesn't exist

My database is called users and the table is called personalinformation so im confused as to why its saying it doesnt exist

Perhaps you have more than one drive , and the settings must be provided with the port of the mysql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM