Jump to content

Sending data to MySQL Database


Miki12

Recommended Posts

Hellow,

At the outset, sorry for any mistakes, but I am using google translator.

Getting to the bottom of it, I get this message five minutes after clicking "Zapisz"

Quote

[2020-08-20 22:44:06] WARNING: notatki_sluzbowe\notatki.lua:6: Database result uncollected after 5 minutes. [Query: INSERT INTO `realrp.notatki`(`ID`, `Tresc`) VALUES (1, dane)

 

Could anyone tell me what I'm doing wrong? I am a novice scriptwriter. I leave the content of the script below.
 


button = {}

Notatki = {}

DBName="realrp"
DBUser="root" 
DBPass="" 
DBHost="localhost" 

function pobieranie_danych()
local DBHandler=dbConnect("mysql", "dbname="..DBName..";host="..DBHost.."", DBUser, DBPass, "share=1") 
local zapisz = dbQuery (DBHandler, "INSERT INTO notatki(ID,tresc) VALUES(?,?)", 1, Notatki.Okno )
end

function otworz_notatki()
showCursor(true, true)
GUI = guiCreateWindow(0.80, 0.70, 0.19, 0.25, "Notatki służbowe", true)
guiWindowSetSizable(GUI, false)

Zamknij = guiCreateButton(10, 27, 114, 24, "Zamknij", false, GUI)
Notatki.Okno = guiCreateMemo(10, 51, 241, 132, "", false, GUI)
Zapisz2 = guiCreateButton(134, 27, 112, 24, "Zapisz", false, GUI)

addEventHandler("onClientGUIClick", Zapisz2, pobieranie_danych, false)
addEventHandler("onClientGUIClick", Zamknij, zamknij_notatki, false)
end

function zamknij_notatki()
	showCursor (false, true)
	guiSetVisible(GUI, false)
end
addCommandHandler("nsluzbowa", otworz_notatki)
Edited by Miki12
Link to comment
  • Moderators
58 minutes ago, Miki12 said:

Could anyone tell me what I'm doing wrong? I am a novice scriptwriter. I leave the content of the script below.

dbQuery is used for retrieving information from the database. Even if you are only inserting data, there is still information returned about the success/failure state.

dbPoll is used to collect that information (from the queryHandle). Since you didn't use that function on the queryHandle = the variable you named `zapisz` , there was no attempt to collect that information, so it was still waiting to be collected and therefore it gave you that warning.

If you do not think you need that information, you can better use dbExec. That is just a one-way trip.

 

Link to comment
  • 2 weeks later...

in the following configuration

 

button = {}

Notatki = {}

DBName="realrp"
DBUser="root" 
DBPass="" 
DBHost="localhost" 

function otworz_notatki()
showCursor(true, true)
GUI = guiCreateWindow(0.80, 0.70, 0.19, 0.25, "Notatki służbowe", true)
guiWindowSetSizable(GUI, false)

Zamknij = guiCreateButton(10, 27, 114, 24, "Zamknij", false, GUI)
Notatki.Okno = guiCreateMemo(10, 51, 241, 132, "", false, GUI)
Zapisz2 = guiCreateButton(134, 27, 112, 24, "Zapisz", false, GUI)
addEventHandler("onClientGUIClick", Zamknij, zamknij_notatki, false)
addEventHandler("onClientGUIClick", Zapisz2, zapisywanie ,false)
end

function zamknij_notatki()
	showCursor (false, true)
	guiSetVisible(GUI, false)
end
addCommandHandler("nsluzbowa", otworz_notatki)

function zapisywanie ()
 polaczono = dbConnect("mysql", "dbname="..DBName..";host="..DBHost.."", DBUser, DBPass, "share=") 
 zapisz = dbExec( polaczono, "INSERT INTO notatki VALUES (?,?)", "aaa", "bbb" )
end

 

the "zapisz" command does not execute, but if I delete "function" and move it to the top, it is written but the later code does not execute.

Link to comment
  • Moderators
4 hours ago, Miki12 said:

the "zapisz" command does not execute, but if I delete "function" and move it to the top, it is written but the later code does not execute.

You will also need to separate clientside from serverside. Red coloured functions are clientside. Orange coloured functions are serverside and blue can be used for both.

Link to comment

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...