Hi all,
error message when match.js is called with insert
thanks
Eric
match.js:53
connection.query('insert into MYTABLE set ' + wREQUEST,
function(err, res) {
^
ReferenceError: connection is not defined
***
main.js
var request = require('request');
var cheerio = require('cheerio');
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'admin',
password : 'secret',
database : 'mydb'
});
connection.connect();
request('http://url/en', function (error, response, html) {
if (!error && response.statusCode == 200) {
var $ = cheerio.load(html);
$('div.expander-button').each(function(i, element){
var a = $(this);
var zurl = a.next().children().children().attr('href');
// Our parsed meta data object
var metadata = {
url: zurl
};
//console.log(zurl);
var a = require('./match')(zurl);
a.extractValue();
});
}
});
connection.end();
***
match.js
module.exports = function(zurl) {
return {
extractValue: function() {
....
....
....
connection.query('insert into MYTABLE set ' + wREQUEST, function(err,
res) {
if (err) throw err;
} ) ;
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/38690d8e-9440-4cbd-bcf3-3b72e892eb98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.