Sign in to follow this  

MySQL Problem

Recommended Posts


[2018-12-16T20:52:23.872] [ERROR] default - DELETE FROM weapon_shops WHERE ID=?
(node:7184) UnhandledPromiseRejectionWarning: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1
    at Query.Sequence._packetToError (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\sequences\Sequence.js:47:14)
    at Query.ErrorPacket (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\sequences\Query.js:77:18)
    at Protocol._parsePacket (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Protocol.js:278:23)
    at Parser.write (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Parser.js:76:12)
    at Protocol.write (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\protocol\Protocol.js:38:16)
    at Socket.<anonymous> (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\Connection.js:91:28)
    at Socket.<anonymous> (C:\Users\Administrator\Desktop\server-files\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 Pool.query (C:\Users\Administrator\Desktop\server-files\node_modules\mysql\lib\Pool.js:199:23)
    at Promise (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1304)
    at new Promise (<anonymous>)
    at Object.dbquery (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1283)
    at Object.query (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:1425)
    at Promise (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100357)
    at new Promise (<anonymous>)
    at C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100335
    at Object.<anonymous> (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:100697)
    at n (C:\Users\Administrator\Desktop\server-files\packages\RP\index.js:1:172)
(node:7184) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
[2018-12-16T20:52:23.878] [WARN] default - 'SELECT * FROM weapon_shops' ends with: 0.991s

const business = require('./sBusiness');
const misc = require('../sMisc');
const i18n = require('../sI18n');

let weaponShops = {};

function createWeaponShopEntities(id, position) {
    let colShape = mp.colshapes.newSphere(position.x, position.y, position.z, 1.0);
    colShape.weaponShopID = id;

    weaponShops[id] = {
        colShape: colShape,

        marker:, new mp.Vector3(position.x, position.y, position.z - 2.25), 2.0, {
            color: [224, 50, 50, 200]

        label:`Waffen Shop (${id})`, position,
            los: true,
            font: 4,
            drawDistance: 20.0,
            color: [255, 255, 255, 255]

        blip:, position, {
            name: "Waffen Shop",
            scale: 1.0,
            color: 0,
            shortRange: true

function deleteWeaponShopEntities(id) {
    if (weaponShops[id]) {
        if (weaponShops[id].colShape) weaponShops[id].colShape.destroy();
        if (weaponShops[id].marker) weaponShops[id].marker.destroy();
        if (weaponShops[id].label) weaponShops[id].label.destroy();
        if (weaponShops[id].blip) weaponShops[id].blip.destroy();

async function loadWeaponShops() {
    const d = await misc.query("SELECT * FROM weapon_shops", (error, rows) => {
        if (e) {
            console.log(`Weapon shop loading failed: ${e.message}`);
        } else {
            rows.forEach((row) => createWeaponShopEntities(row.ID, new mp.Vector3(row.ShopX, row.ShopY, row.ShopZ)));
            console.log(`Loaded ${rows.length} weapon shop(s).`);

async function createWeaponShop(position) {
    return new Promise((resolve, reject) => {
        const d = misc.query("INSERT INTO weapon_shops SET ShopX=?, ShopY=?, ShopZ=?", [position.x, position.y, position.z], (error, result) => {
            if(e) {
                console.log(`Weapon Shop adding failed: ${e.message}`);
            } else {
                createWeaponShopEntities(result.insertId, position);

async function deleteWeaponShop(id) {
    return new Promise((resolve, reject) => {
        const d = misc.query("DELETE FROM weapon_shops WHERE ID=?", [id], (error, result) => {
            if(e) {
                console.log(`Weapon Shop removing failed: ${e.message}`);
            } else {
                if(result.affectedRows > 0) {
                    delete weaponShops[id];

Irgend wie fehlt da ein Catch oder wie darf ich den Fehler verstehen?

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.