2017-04-08 58 views
-1

這是錯誤,但我無法找到它。從phpMyAdmin的SQL控制檯運行時,運行查詢FINTSyntaxError:missing)在javascript中的參數列表後

var query = connection.query('Select distinct a.*, IFNULL(b.scannerid,'Not Available') AS `scannerid`, IFNULL(date(b.datetime),'Not Available') as datetime, IFNULL(b.status,'Absent') AS `status` from studentdetails a LEFT OUTER JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime) = CURRENT_DATE',function(err,rows) 

錯誤:

SyntaxError: missing) after argument list 
     at createScript (vm.js:53:10) 
     at Object.runInThisContext (vm.js:95:10) 
     at Module._compile (module.js:543:28) 
     at Object.Module._extensions..js (module.js:580:10) 
     at Module.load (module.js:488:32) 
     at tryModuleLoad (module.js:447:12) 
     at Function.Module._load (module.js:439:3) 
     at Module.require (module.js:498:17) 
     at require (internal/module.js:20:19) 
     at Object.<anonymous> (/home/ubuntu/Attendance system/app.js:13:24) 

的JavaScript代碼:

exports.getattendance = function(req, res){ 

     req.getConnection(function(err,connection){ 
       var query = connection.query('Select distinct a.*, 
      IFNULL(b.scannerid,'Not Available') AS `scannerid`, 
      IFNULL(date(b.datetime),'Not Available') as datetime, 
      IFNULL(b.status,'Absent') AS `status` from studentdetails a LEFT OUTER 
      JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime) 
      = CURRENT_DATE',function(err,rows) 
       { 
        if(err) 
         console.log("Error Selecting : %s ",err); 
        res.render('showreport',{page_title:"Attendance Report Generated",data:rows}); 

       }); 

       //console.log(query.sql); 
      }); 

     }; 
+0

看看嵌套的單個問題 – Jens

+0

問題區域是引號,換句話說就是'\'不可用\「 – Satpal

+1

你不能用新行符將行字符串打斷。閱讀javascript中的多行字符串 – dfsq

回答

1

行情使用反引號 嘗試錯誤使用(`)

例如:

exports.getattendance = function(req, res){ 

    req.getConnection(function(err,connection){ 
      var query = connection.query(`Select distinct a.*, IFNULL(b.scannerid,'Not Available') AS 'scannerid', IFNULL(date(b.datetime),'Not Available') as datetime, IFNULL(b.status,'Absent') AS 'status' from studentdetails a LEFT OUTER JOIN discovereddevices b ON a.bluetoothid = b.blueid and date (b.datetime) = CURRENT_DATE()`, 
      function(err,rows) 
       if(err) 
        console.log("Error Selecting : %s ",err); 
       res.render('showreport',{page_title:"Attendance Report Generated",data:rows}); 

      }); 

      //console.log(query.sql); 
     }); 

    }; 

編輯:

而且CURRENT_DATE()應該是一個功能!

+0

不幸運!仍然錯誤仍然存​​在 – Legend

+0

@yuvasreekalaiselvan可以üPLZ嘗試編輯答案 –

+0

非常感謝!它工作完美! – Legend

相關問題