Is this working well? i'm kind noob at such things as this??
Is this working well? i'm kind noob at such things as this??
Fucking. Awesome. You rule Andy. King'ed.
This is just great! I noticed a big bug though. When it tries to fetch a NULL value it just crashes. This is a quite big problem here, I hope you can find the problem that's causing this...
If you can give me a minimal database setup and script that causes the error, I'll try and fix it over my Christmas break.Robbis_1 posted:
Alright, here's an export, I've cut down the database, but it should still work (unless I removed something I shouldn't remove):andyvincent posted:
-- phpMyAdmin SQL Dump -- version 2.11.1 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Dec 19, 2007 at 02:16 PM -- Server version: 5.1.22 -- PHP Version: 5.2.2 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `sourcebans` -- -- -------------------------------------------------------- -- -- Table structure for table `sb_admins` -- CREATE TABLE IF NOT EXISTS `sb_admins` ( `aid` int(6) NOT NULL AUTO_INCREMENT, `user` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL DEFAULT '', `password` varchar(128) NOT NULL, `gid` int(6) NOT NULL, `email` varchar(128) NOT NULL, `validate` varchar(128) NOT NULL, `extraflags` int(10) NOT NULL, `immunity` int(10) NOT NULL DEFAULT '0', `srv_group` varchar(128) DEFAULT NULL, `srv_flags` varchar(64) DEFAULT NULL, `srv_password` varchar(128) DEFAULT NULL, PRIMARY KEY (`aid`), UNIQUE KEY `user` (`user`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=56 ; -- -- Dumping data for table `sb_admins` -- INSERT INTO `sb_admins` (`aid`, `user`, `authid`, `password`, `gid`, `email`, `validate`, `extraflags`, `immunity`, `srv_group`, `srv_flags`, `srv_password`) VALUES (1, 'Killer HAHA', 'STEAM_0:0:123456', '', -1, 'NULL', '0', 1106705, 0, 'Server Admin', '', ''), (0, 'CONSOLE', 'STEAM_ID_SERVER', '', 0, '', '', 0, 0, NULL, NULL, NULL);
Here's the code I was using:
-- Connect (this works just fine) local Database, Error = mysql.connect(Host, Username, Password, DatabaseName) if (Database == 0) then print("MySQL ERROR: " .. Error) return end -- Get the whole admin/member table -- THIS IS WHERE IT FAILS, Doesn't even print error local Members, Working, Error = mysql.query(Database, "SELECT `authid`,`srv_group` FROM `sb_admins`") if (not Working) then print("MySQL ERROR: " .. Error) return end -- More unrelated code...
Alright, so when I tried changing the srv_group of CONSOLE to something else than NULL, it worked just fine.
I want to use this to have global CVARS on my servers. Is it possible to use player stats on the two servers I have?
Also, is there such things as a good tutorial on how to use this? Thank you
Thanks very much man you are awesome
How can I get the last inserted Primary Key? From PHP I'm used to something like $mysql->last_insert_id()
Currently you can't. I'll add it in.
Ok, thank you.
[list][*]1.8 - 8th January 2008
[list][*]Added mysql.last_insert_id() to get the last ID used by an AUTO_INCREMENT field.[/list][/list]
Description: Retrieves the last ID used by an AUTO_INCREMENT_FIELD in an INSERT statement.
Returns: number and error message. If number is false, the function failed (for whatever reason).
local test,error = mysql.last_insert_id(db); if (not test) then Msg(error .. "\n") else then Msg( "Last id = " .. tostring(test) ) end
[list][*]Zip file[*]Source code (for the paranoid)[/list]
Neeto. Thank you much :D
Is there a tutorial anywhere on how to use this and MySQL? I have a MySQL database, but I do not know how to use it. Thank you.
That was fast! Thanks.
This doesn't work for me in the new Gmod--it keeps saying "ERROR! Module 'mysql' not found!"
It's on a dedicated server, if that makes any difference.
Ah, I see. Binary modules don't load from addons, so you have to put them in the lua folder manually.
I have the same problem!dvondrake posted:
The libmySQL.dll should be at the same place as before.Ben Build posted:
Go to gm_mysql\lua\ in the addon that you downloaded and cut the 2 dll files. Paste them in \garrysmod\lua\includes\modules. That will make it work. You can remove the addon now, because it just contain an example now.
I'm on a dedicated server, and I cannot get this module to work. I put the libmySQL.dll in the folder outside garrysmod where the HL2.exe is normally. I put the two dlls in the lua/includes/modules folder (not addons!) and it does not work.
In server console, I do: "lua_run require( "mysql" )", and it just tells me it cannot find the mysql module.
It HAS worked before the update though.
Whaddup with this.
Same here.DarkCybo1 posted:
Yeah. The same for me.
Seems not to load anything.
Forget about it. I did just use the wrong folder. Everything works fine now.
Is it possible to add a function called mysql_num_rows ? I need it or is there another way to check if there is someone already in a Database and if not that he create an insert for the user ?
Can't you use "SELECT count(*) as total FROM [...] WHERE [...]" and then check if total is "0" or "1"?
Something more I miss, is a option to change the charset.
basically it is
The only problem i notice is that by going that route, you can't really tell if there is a record or not. If you need to i think this would workCode:INSERT IF NOT EXISTS INTO table (something,somethingmore) VALUES(1,2)
local stuffhere,succ,isok = mysql.Query(connectionid,"SELECT index from table where steamid="..ply:SteamID()) if !stuffhere then --create stuff else --user does exist so do something else(load?) end
if i used a BEGIN statement and then a COMMIT statement after like 40 queries in a for loop, would that improve performance because it seems to lock up the server for about 10 seconds
Also, say you had this
Would both of the above queries fail? if not do i just put in a commit afterwards likelocal savestuff = gdatabase.Query("BEGIN",3) local savestuff = gdatabase.Query("UPDATE table SET nonexistantcolumn='something'",3) local savestuff = gdatabase.Query("UPDATE table2 SET existingcolumn='something'",3) local savestuff = gdatabase.Query("COMMIT",3)
if succ then commit end
Still can't use the dll after the update.
Says it doesn't exist when it does.
did you make sure to put the dll into garrysmod\lua\includes\modules instead of the one in the addons folder?high posted:
Yes, I compared its path to where it said it didn't exist and they were the same. I am guessing this error is because the dll is still built for the old system and it can't be found be cause it errors on load.Neico posted:
Can you please update andy.
works just fine and that it isn't compiled with the newest Interface doen't mean it won't work since garry made it so that all older versions still works wich they do very fine so the problems is on your side not on the modules one maybe you can give out some extented error messages like what path it search und where relative to it the module is
Everything is on my C:\.Neico posted:
Also it gives the same error with the test.lua in the addons.
Also that other dll is in
Also I have .net framework 1.1, 2.0 and 3.5.
Works fine for me. You must of installed something wrong.high posted:
Well I posted above that it is in the right area...tomato3017 posted:
edit: Whooops! I put the lib dll in the wrong folder so it was failing to load.
Sorry, my bad.
Ok so to explain it right i use your folder name to show it right:high posted:
C:\Program Files\Steam\steamapps\high6\garrysmod\garrysmod\lu a\includes\modules\<gmsv_mysql.dll | gmcl_mysql.dll | gm_mysql.dll>
since you can load the module in those 3 ways:
gmsv for server module
gmcl for client module
gm for shared module wich is the common way since mysql has no different content for client and server but oh well andy used the sv cl way
if it now works then congratulation :D
Well, it seems that escaping nil causes the game to instantly crash, or something.
I have some code like this:
for col in pairs(bbb.databaselayout.users) do file.Write("debug.txt","Begin col pairs. Data: "..tostring(data[col])) query=query.." "..col.."=\""..bbb.escape(data[col]).."\"," //column="data", end
(The file.write is debugging it, when you can't see any console output because it crashes as soon as I load the script. I had to reload the game about 10 times to find the bug!)
But after I traced the error, the debug.txt file contained this:
bbb.escape is a simple function,Code:Begin col pairs. Data: nil
function bbb.escape(input) return mysql.escape(bbb.db,input) end
Could mysql.escape cause crashes if passed a nil value?
this dont work now
anybody have any success with this? put the files in every folder and still nothing.
C:\Program Files\Steam\steamapps\USERNAME\garrysmod\libmysql. dll
C:\Program Files\Steam\steamapps\USERNAME\garrysmod\garrysmod \lua\includes\modules\
this is what i have done and get failed connection, i am using this with uban on ulx
Global ban failed! See server console for error.
AviZ: !gban AviZ 5 "test this"
Did you over see my last post?
Link isn't working
So will that basically do more than 1 threaded query without dropping the connection?