mysql запрос через командную строку отвечает результатом через скрипт выдает ошибку
Cannot read property 'photo' of undefined
connection.connect();
query='SELECT `id`,`prod`,`name`,`description`,`photo`,`price`,`popularity`,`sale`,`dbesplat`,`promokodi`,`presents`,`newtov`,`garantprod`,(`price` -`price` / 100 * `sale`) AS `tsale` FROM `smartphone` ';
connection.query(query, function(err, rows, fields) {
if (err) {
res.status(500).json({"status_code": 500,"status_message": "internal server error"});
console.log(err);
} else {
// Loop check on each row
var rowlenght=rows.length+1;
for (var i = 0; i < rows.length; i++) {
// Create an object to save current row's data
var smartphopne = {
'id':rows[i].id,
'prod':rows[i].prod,
'name':rows[i].name,
'photo':rows[i].photo,
'description':rows[i].description,
'price':rows[i].price,
'sale':rows[i].sale,
'len':rowlenght,
'tsale':rows[i].tsale,
'prmin':prmin,
'prmax':prmax,
'cprmin':req.cookies.prmin,
'cprmax':req.cookies.prmax,
'vprodaj':req.cookies.vprodaj,
'soskidkoi':req.cookies.soskidkoi,
'dbesplat':req.cookies.dbesplat,
'promokodi':req.cookies.promokodi,
'presents':req.cookies.presents,
'newtov':req.cookies.newtov,
'uctov':req.cookies.uctov,
'garantprod':req.cookies.garantprod,
'oswin':req.cookies.oswin,
'osios':req.cookies.osios,
'osandrod':req.cookies.osandrod,
};
// Add object into array
smartphopneList.push(smartphopne);
}
// Render index.pug page using array
res.render('index', {"smartphopneList": smartphopneList});
}
});
connection.end();
<%for(var i=0;i<smartphopneList[0]['len'];i++){ %>
<tr>
<td class="leftitem" style="padding:10px;border-left:1px solid silver;border-top:1px solid silver;border-bottom:1px solid silver;">
<img class="imgind" style="height:200px;width:200px" src="<%= smartphopneList[i]['photo'];%>">
<p>
Производитель: <%= smartphopneList[i]['prod'];%><br>
Модель: <%= smartphopneList[i]['name'];%><br>
Цена: <%= smartphopneList[i]['price'];%><br>
Цена со скидкой: <%= smartphopneList[i]['tsale'];%>
</p>
</td>
<td class="rightitem" style="border-top:1px solid silver;border-bottom:1px solid silver;">
<%= smartphopneList[i]['description'];%>
</td>
<td style="text-align:center;border-right:1px solid silver;border-top:1px solid silver;border-bottom:1px solid silver;">
<p><a href="/somesmart/<%= smartphopneList[i]['id'];%>" style="color:white;background-color:orange;padding:4px;border-radius:3px;font-weight:bold;">Подробнее</a></p>
<p><a href="/basket/<%= smartphopneList[i]['id'];%>" style="color:white;background-color:green;padding:4px;border-radius:3px;font-weight:bold;">В Корзину</a></p>
</td>
</tr> <%}%>