Хочу через пост запрос добавить в таблицу несколько новых полей которые ввел пользователь.
app.post('/moderator', function(request, response) {
if (!request.body) return sendStatus(400);
connection.query('INSERT INTO news(`title`, `text`) VALUES(' + request.body.title + ',' + request.body.text + ')', function(err, result) {
if (err) throw err;
});
response.redirect('/moderator');
response.end();
});
Но в итоге получаю данную ошибку:
Error: ER_BAD_FIELD_ERROR: Unknown column 'фвфвфв' in 'field list'
at Query.Sequence._packetToError (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/Protocol.js:278:23)
at Parser.write (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/Connection.js:502:10)
at Socket.emit (events.js:182:13)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
--------------------
at Protocol._enqueue (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Connection.query (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/mysql/lib/Connection.js:200:25)
at /media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/server.js:48:13
at Layer.handle [as handle_request] (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/layer.js:95:5)
at next (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/route.js:137:13)
at Route.dispatch (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/layer.js:95:5)
at /media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/index.js:281:22
at Function.process_params (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/index.js:335:12)
at next (/media/selin/Data/Documents/WORK/My Projects/Web Developing/GitHub/IgorZaviryukhaA2Lab/lesson_5/5-2_News/node_modules/express/lib/router/index.js:275:10)
В консоль данные выводятся, имена ячеек правильные, и атрибуты name также совпадают.
<form id="add_post" class="d-flex justify-content-between" method="post">
<div class="add-post__left">
<h3>Add new post</h3>
<div class="add-post__form-set">
<input type="text" name="title" placeholder="Title">
<textarea name="text" placeholder="Text"></textarea>
</div>
</div>
<div class="add-post__right">
<button type="submit">Post</button>
</div>
Айфон мало держит заряд, разбираемся с проблемой вместе с AppLab
Перевод документов на английский язык: Важность и ключевые аспекты
При таком коде скролл прекрасно и плавно скроллит на iPhone , но , время от времени при касаниях и скроллах - скролл перестает работать вообщеНесколько...
Возможно ли указать значение option, которое будет выбираться по умолчанию при загрузке страницы? Пробовал через selected и selected="selected"Результат...