# MySQL UDFs (without ODBC)

## Recommended Posts

i have a php code that i want to translate from php to autoit, how would i do this?

$results = mysql_query("SELECT * FROM online_order WHERE status='ordering") or die(mysql_error());$row = mysql_fetch_array( $results );$old_item = $row['item'];$first_name = $row['first_name'];$old_items = unserialize($old_item); and display the info in a loop$old_items is now an array and $first_name is just a varchar with the users name If anyone is still watching this thread: I would like to know pretty much the same thing, i.e. whether or not there is a possibility to access fields by name instead of index. I would like to do this after using "_MySQL_Fetch_Row"... is there maybe a possibility to access rows as objects? Edited by level20peon ##### Link to post ##### Share on other sites • 1 year later... • Replies 189 • Created • Last Reply #### Top Posters In This Topic #### Top Posters In This Topic #### Popular Posts MySQL UDFs using libmysql.dll functions: most functions from MySQL API all are prefixed with an underscore: _MySql... e.g.: _MySQL_Real_Query( sometimes parameters are chaged - read function descripti I don't get it. @mLipok has polished (pun intended) a nice ADO UDF which works flawlessly. Why insist on using another one which causes issues? @ProgAndy I like anything that smells to SQL !! Unfortunately you link does not work (for me ?). Rgds ptrex #### Posted Images any idea how to send query with utf8 charset? ##### Link to post ##### Share on other sites Doesn't MySQL accept UTF16 input? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks. Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here RegExp tutorial: enough to get started PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try. SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager. An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work. SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well) A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages! SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) ##### Link to post ##### Share on other sites I don't know which charset AutoIt use to send string but when I try to insert this string to my MySQL database then it look that way when I explore table using MySQL Administrator Please note that my MySQL database table setting is set to utf-8 ##### Link to post ##### Share on other sites @maniootek I have instaled MySQL on my computer and on remote host, I do not have any problem like that. How you are connecting to MySQL ? I just check how this is set on my remonte host, and this are exactly the same settings. Signature beginning: Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * * IE on Windows 11 for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer "Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2022-03-07 ##### Link to post ##### Share on other sites I am connecting to MySQL with UDF from forum thread we are writing ##### Link to post ##### Share on other sites I have found function in this UDF called _MySQL_Set_Character_Set() which I added to my script but it still does not save properly polish chars into database. this is the functions order I use: _MySQL_InitLibrary()$conn = _MySQL_Init()
_MySQL_Real_Connect($conn,$dbhost, $dbuser,$dbpass, $dbname) _MySQL_Character_Set_Name($conn) ;return 'latin1', I think this is default
_MySQL_Set_Character_Set($conn, "utf8") _MySQL_Character_Set_Name($conn) ;return 'utf8' - properly
_MySQL_Real_Query($conn,$query)

Now it look that way in database:

any idea?

One more thing. When I execute mysql query from autoit to read values from database then I can see polish chars normally (with latin1 insert and latin1 select).

Edited by maniootek
##### Share on other sites
On ٧‏/١٢‏/٢٠٠٨ at 11:15 PM, ptrex said:

@ProgAndy

I like anything that smells to SQL !!

Unfortunately you link does not work (for me ?).

Rgds

ptrex

ProgAndy good work

What is the difference between using the Windows ODBC libraries and the use of MySQL library

Is there a difference in speed and possibilities

Knowing that MySQL library subsidiary of special software and ODBC libraries subsidiary of developer Windows system

Edited by wolf9228

صرح السماء كان هنا

##### Share on other sites

I don't get it.

@mLipok has polished (pun intended) a nice ADO UDF which works flawlessly. Why insist on using another one which causes issues?

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

##### Share on other sites
• 2 weeks later...
On 26.06.2016 at 10:08 PM, jchd said:

I don't get it.

@mLipok has polished (pun intended) a nice ADO UDF which works flawlessly. Why insist on using another one which causes issues?

I have many scripts based on this UDF and I simply don't want to rewrite huge part of code.

##### Share on other sites
18 minutes ago, maniootek said:

I have many scripts based on this UDF and I simply don't want to rewrite huge part of code.

So as I understand it work before, and now it does not work ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * *
IE on Windows 11 for other useful stuff click the following button:

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt *

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
, be   and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2022-03-07

##### Share on other sites

Before I didn't use polish characters.

Let me show you a list of things I've done so far:

1. I have set "Encoding" to "UTF-8" in SciTE

2. I have added these lines into SciTEGlobal.properties file

utf8.auto.check=2 #detect utf8 and do not add BOM
output.code.page=65001 #utf8
code.page=65001 #utf8

3. In MySql server I have set default encoding to utf8/utf8_global_ci for specified table and column

4. I have set connection charset to utf8 and also send special query "SET NAMES"

_MySQL_InitLibrary()
$conn = _MySQL_Init() _MySQL_Real_Connect($conn, $dbhost,$dbuser, $dbpass,$dbname)
_MySQL_Set_Character_Set($conn, "utf8") _MySQL_Character_Set_Name($conn) ;return 'utf8' - properly
$query_charset = "SET NAMES 'utf8' COLLATE 'utf8_global_ci'"$query_insert = "INSERT INTO tablename.columnname (test) VALUES ('aąącćeęlłnńoósśzżzź')"
_MySQL_Real_Query($conn,$query_charset)
_MySQL_Real_Query($conn,$query_insert)

nothing worked.

EDIT:

I HAVE FOUND SOLUTION, PROBLEM IS RESOLVED

I think problem was with the libmysql.dll which simple does not support utf8. I have googled "libmysql.dll utf8" and found this:

I have changed charset in my code from utf8 to cp1250 and now it shows all polish chars.

_MySQL_InitLibrary()
$conn = _MySQL_Init() _MySQL_Real_Connect($conn, $dbhost,$dbuser, $dbpass,$dbname)
_MySQL_Set_Character_Set($conn, "cp1250") _MySQL_Character_Set_Name($conn)
$query_insert = "INSERT INTO tablename.columnname (test) VALUES ('aąącćeęlłnńoósśzżzź')" _MySQL_Real_Query($conn, $query_insert) Edited by maniootek found solution ##### Link to post ##### Share on other sites Well done. You are still growing up in my eyes Keep learning. mLipok Signature beginning: Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * * IE on Windows 11 for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer "Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2022-03-07 ##### Link to post ##### Share on other sites That isn't a perfect solution. I suspect that the problem you experience is due to the fact that you don't pass UTF8 strings to the library. Remember that native AutoIt strings are UTF16-LE encoded. If the library expects str type as parameter, then AutoIt will convert UTF16 to the locale ISO codepage you use. Try converting UTF16 strings to UTF8 before passing them by means of _WinAPI_WideCharToMultiByte with output codepage = 65001. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks. Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here RegExp tutorial: enough to get started PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try. SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager. An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work. SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well) A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages! SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) ##### Link to post ##### Share on other sites I have been testing the stability of using mysqllib.dll & the associated UDF, like this fine one. However, I have run into a problem for which I don't see an elegant solution. Specifically, once the connection to the server is lost (I have only tested when I lose internet connection so far), the DLL becomes non-responsive and then crashes the AutoIT script with an exit code of 3221225477. I will post the simple test below, which is an adaptation of @ProgAndy's test.au3. I added in a response to a lost connection, including a poll until internet connection is re-established. I have tried different versions of the mysqllib.dll, but to no avail. Also, while there are plenty of posts out there on this issue, I have not found a good work-around. #include "mysql.au3" Global$MysqlConn

_MySQL_InitLibrary()
$MysqlConn = _MySQL_Init()$connected = _MySQL_Real_Connect($MysqlConn,"****","adminuser","****","wellchec", 3306) While True$ping = _MySQL_Ping($MysqlConn) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') :$ping = ' &     $ping & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console If$ping=1 Then _reconnectDB($MysqlConn)$sleepTime = Random(1000,20000,1)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sleepTime = ' &$sleepTime & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
Sleep($sleepTime) WEnd _MySQL_Close($MysqlConn)
_MySQL_EndLibrary()

Func _reconnectDB($MysqlConn) _MySQL_Close($MysqlConn)
_MySQL_EndLibrary()

Do
Sleep(1000)

_MySQL_InitLibrary()
If @error Then Exit MsgBox(0, '', "")
$MysqlConn = _MySQL_Init() _MySQL_Real_Connect($MysqlConn,"****","adminuser","****","wellchec", 3306)
EndFunc ; _reconnectDB()

Here is the console listing after a run where I disconnect from my wireless network, then reconnect.

>Running:(3.3.14.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\Public\Desktop\Pt.Data\Reports\mysql(20160710010357)\test.au3"
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
@@ Debug(19) :  $ping = 0 >Error code: 0 @@ Debug(24) :$sleepTime = 15798
>Error code: 0
@@ Debug(19) :  $ping = 1 >Error code: 0 @@ Debug(24) :$sleepTime = 5969
>Error code: 0
!>09:33:32 AutoIt3.exe ended.rc:-1073741819
+>09:33:32 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 81.51

##### Share on other sites
• 4 weeks later...

With:

****

; Zugriff
MsgBox(0, '', "Zugriff - alles in ein 2D Array")
$array = _MySQL_Fetch_Result_StringArray($res)
_ArrayDisplay($array) **** Can "read" (show) the values on database.... i can use those values and make changes... So i wanna know how save the changes ? ##### Link to post ##### Share on other sites one word.... WOWWWW ##### Link to post ##### Share on other sites On 3.08.2016 at 1:19 PM, editcheck said: So i wanna know how save the changes ? you should use SQL Query : INSERT INTO ....... or UPDATE .... Signature beginning: Please remember: "AutoIt"..... * Wondering who uses AutoIt and what it can be used for ? * * IE on Windows 11 for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution to others projects or UDF based on others projects: * _sql.au3 UDF * POP3.au3 UDF * RTF Printer - UDF * XML.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer "Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming" , be and \\//_. Anticipating Errors : "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2022-03-07 ##### Link to post ##### Share on other sites • 2 weeks later... On 9/8/2016 at 8:09 PM, mLipok said: you should use SQL Query : INSERT INTO ....... or UPDATE .... Hi, can give me a sample ? ty Edit: resolved, ty Edited by editcheck ##### Link to post ##### Share on other sites • 3 weeks later... Hello, sorry bumping an old thread but is there an way to know the cause of failure in _MySQL_Real_Query function? EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion ##### 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 • ### Recently Browsing 0 members No registered users viewing this page. • ### Similar Content • By DevMode welcome I need help dealing with a C++ DLL Specify that I need help with how to use this function struct libusb_device; typedef struct libusb_context libusb_context; ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,libusb_device ***list); My problem is how to deal with "libusb_device ***list" my code$libusb_device = DllStructCreate("PTR") Func libusb_init() $Var = DllCall($libusb0, "ptr", "libusb_init",'ptr',$_libusb_device_handle_Ptr) If @error Then Return False Return$Var[1] EndFunc Func libusb_get_device_list() MsgBox(0,VarGetType($_libusb_device_handle_Ptr),$_libusb_device_handle_Ptr) $Var = DllCall($libusb0, "int", "libusb_get_device_list","ptr",$_libusb_device_handle_Ptr,"ptr*",POINTER(POINTER($libusb_device))) $Error = @error If$Error Then Return False MsgBox(0,VarGetType($Var),$Error&@CRLF&$Var) _ArrayDisplay($Var) Return $Var[1] EndFunc Thank you iLibUSB.dll iLibUSB_32.dll libusb.h • Hi all, My programming knowledge is very basic. I have an old script that creates shares and assign permissions. It normally registers SetAcl.ocx if necessary and creates an object to assign permissions. The command that registers SetAcl was apparently working fine under Windows 7 but is not working under Windows 10. RunWait("regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) As I'm logged in as admin, I changed this command to : RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE) It seems to terminate correctly but the script still doesn't work as expected. To check that, I've created that small script : Local$objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj($objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object not created. Registering SetAcl.ocx" & @CRLF) Local$result = RunAsWait(@UserName, "", "", 0, "regsvr32.exe path\to\setacl.ocx /s", "", @SW_HIDE); Use of my admin username to elevate CMD ConsoleWrite("Return code : " & $result & @CRLF) ConsoleWrite("Creating object" & @CRLF)$objSetAcl = ObjCreate("SETACL.SetACLCtrl.1") If IsObj(\$objSetAcl) Then ConsoleWrite("Object successfully created." & @CRLF) Else ConsoleWrite("Object creation failed." & @CRLF) EndIf EndIf It tries to register SetAcl.ocx, return code 0 seems to be fine but still can't use SetAcl.
But if I go to CMD as admin, run the regsvr32 command and restart my script, it can create the object without issue.
I know my poor knowledge makes me miss something. Anyone can help me figure this out ?

• Dear members of the forum,
I'm working on a project in which I have to use Image recognition technique.
Due to client restrictions, I couldn't use AutoIt for this project.
Is there a way to use this DLL "ImageSearchDLL.dll" (which is used to do image recognition steps in AutoIt) in VB.Net to achieve the same result?
I have used this DLL few years before and got good results. If there is a latest version of this DLL and if you can share it, that will be helpful too.
Any guidance is deeply appreciated.

• Hi AutoIt Scripters/Programmers. I have a question about MIME Tools for Notepad++:
I've recently found a UDF about Base64 in forum, but they can't decode\encode correctly some emojis , other UTFs and etc. so i decided to use mimeTools.dll of Notepad++ or main site
My problem is how to use this dll in AutoIt Language?

• Good morning Forums
In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers.
I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to
implement and understand at the same time.
The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on.
Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot.
For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them.
At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere.
So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing.

Best Regards and Stay at home 🏡

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...