[英]phpMyAdmin and node.js
I have created aa database called users in phpmyadmin and a table called personalinformation.我在 phpmyadmin 中创建了一个名为 users 的数据库和一个名为 personalinformation 的表。 I can connect to the database just fine using node.js javascript with this code:
我可以使用 node.js javascript 和以下代码很好地连接到数据库:
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等,错误消息是错误:ER_NO_SUCH_TABLE:表'users.personalinformation'不存在
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也许你有不止一个驱动器,设置必须与mysql的端口一起提供
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.