SQL Errors by Mysqloo or tmysql4
Last read Never
Hello my Guys :),
I am looking for a person who can help me very briefly
I found a game mode and try to get it started But unfortunately this does not work, because he can not connect to the database
Would one be willing to show me how he could connect via SQL
I think he is works and i dont know the Shit Code
--[[---------------------------------------------------------
File: sv_database.lua
Desc: Handles database connection and provides query function
-----------------------------------------------------------]]
require("tmysql4")
RP.SQL = RP.SQL or {}
RP.SQL.connected = false
RP.SQL.DBName = "crp"
RP.SQL.DBUser = "gmod"
RP.SQL.DBHost = "62.75.253.86"
RP.SQL.DBPassword = "PUTYOURPASSWORDHERE"
RP.SQL.DBPort = 3306
--[[---------------------------------------------------------
Name: Escape
Desc: Escapes string for SQL
-----------------------------------------------------------]]
function RP.SQL:Escape(sqlstring)
local allowedStrings = {}
if table.HasValue(allowedStrings,sqlstring) then
return sqlstring
end
return "'"..self.db:Escape(tostring(sqlstring)).."'"
end
--[[---------------------------------------------------------
Name: InitializeDatabase
Desc: Connects to database
-----------------------------------------------------------]]
function RP.SQL:InitializeDatabase()
RP.SQL.db, error = db or tmysql.initialize(RP.SQL.DBHost, RP.SQL.DBUser, RP.SQL.DBPassword, RP.SQL.DBName, RP.SQL.DBPort)
if not error then
print("[RP] MySQL Connected")
RP.SQL.connected = true
return true
else
print("[RP] MySQL Error: " .. error)
RP.SQL.connected = false
return false
end
end
--[[---------------------------------------------------------
Name: Query
Desc: Queries the database, retrys if connection failed
Parameters:
sql: Query string, don't forget to escape with variables
callback: Function called on success; with data as parameter
-----------------------------------------------------------]]
function RP.SQL:Query(sql, replacements, callback, errcallback)
if RP.SQL.connected then
if replacements and istable(replacements) then
for k, v in pairs(replacements) do
sql = string.Replace(sql, "%"..k.."%", self:Escape(v))
end
end
print("[RP][DEBUG] " .. sql)
RP.SQL.db:Query(sql, function(results)
if results[1].status then
if callback and isfunction(callback) then
callback(results[1]["data"])
end
else
print("[RP] Error while executing Query:\n"..results[1].error.."\n\nQuery:\n"..sql)
if errcallback and isfunction(errcallback) then
errcallback(results[1]["error"])
end
end
end)
else
print("[RP][ERROR] Tried to executed Query while not connected to database!")
end
end
Here the Errors
[RP][ERROR] Tried to executed Query while not connected to database!
[RP][ERROR] Tried to executed Query while not connected to database!
[RP][ERROR] Tried to executed Query while not connected to database!
[RP][ERROR] Tried to executed Query while not connected to database!
[ERROR] stack overflow
1. istable - [C]:-1
2. Query - gamemodes/standard/gamemode/sv_database.lua:93
3. Query - gamemodes/standard/gamemode/sv_database.lua:99
4. Query - gamemodes/standard/gamemode/sv_database.lua:99
5. Query - gamemodes/standard/gamemode/sv_database.lua:99
6. Query - gamemodes/standard/gamemode/sv_database.lua:99
7. Query - gamemodes/standard/gamemode/sv_database.lua:99
8. Query - gamemodes/standard/gamemode/sv_database.lua:99
9. Query - gamemodes/standard/gamemode/sv_database.lua:99
10. Query - gamemodes/standard/gamemode/sv_database.lua:99
11. Query - gamemodes/standard/gamemode/sv_database.lua:99
12. Query - gamemodes/standard/gamemode/sv_database.lua:99
13. Query - gamemodes/standard/gamemode/sv_database.lua:99
14. Query - gamemodes/standard/gamemode/sv_database.lua:99
15. Query - gamemodes/standard/gamemode/sv_database.lua:99
[RP][ERROR] Tried to executed Query while not connected to database!
what does it has to do with gmodstore
i think here is more Scripter / Developer
try: gmodstore.com/jobs
I have a Ban! From 2 Years I dont know Unban for jobs xD
I think you can help me to fix it :)
So here's the problem: 
This is your personal problem, and GmodStore is the wrong site for sth. like this. Try seeking help on Facepunch.
Users viewing this thread
Nobody