20Ice18 Posted June 16, 2023 Share Posted June 16, 2023 (edited) I encountered issues while attempting to use the EzMySql UDF made by @Yoriz Specifically, I faced difficulties in creating the .dll file using http://www.mediafire.com/?ztmzzlozzlw, which turned out to be empty. While running the AutoIt script, I encountered some undeclared global and local variables, which I tried to rectify. However, despite my efforts, I am still encountering the following error when running the script: After this MsgBox it creates empty .dll file in script directory. If anyone knows what could be causing this please let me know. Edited June 16, 2023 by 20Ice18 ❤️ Link to comment Share on other sites More sharing options...
20Ice18 Posted June 16, 2023 Author Share Posted June 16, 2023 (edited) I'm getting error that variable is not declared even tho its declared right here EzMySql.au3" (98) : ==> Variable used without being declared.: $hEzMySql_Dll = DllOpen($hEzMySql_DllLoc) ^ ERROR Edited June 16, 2023 by 20Ice18 ❤️ Link to comment Share on other sites More sharing options...
20Ice18 Posted June 16, 2023 Author Share Posted June 16, 2023 I think I fixed that by just declaring them again but now im getting error while executing a query expandcollapse popupFunc data_computers_insert() Local $serialNumber Local $computerName Local $submissionDate Local $sqlQuery ; Start the MySQL connection _EzMySql_Startup() ; Open the connection to the database _EzMySql_Open($str_db_host, $str_db_user, $str_db_password, $str_database, "3306") If @error Then MsgBox(16, "Error", "Failed to open the MySQL connection.") Return EndIf ; Set the values for the computer $serialNumber = RegRead("HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\BIOS", "SystemProductName") If @error Then MsgBox(16, "Error", "Failed to read the serial number from the registry.") _EzMySql_Close() _EzMySql_ShutDown() Return EndIf $computerName = @ComputerName $submissionDate = @YEAR & "-" & @MON & "-" & @MDAY ; Build the SQL query $sqlQuery = "INSERT INTO Computer (serial_number, computer_name, submission_date) VALUES ('" & $serialNumber & "', '" & $computerName & "', '" & $submissionDate & "')" ; Execute the query _EzMySql_Exec($sqlQuery) If @error Then MsgBox(16, "Error", "Failed to execute the SQL query.") _EzMySql_Close() _EzMySql_ShutDown() Return EndIf _EzMySql_Close() _EzMySql_ShutDown() EndFunc this one : MsgBox(16, "Error", "Failed to execute the SQL query.") ❤️ Link to comment Share on other sites More sharing options...
Andreik Posted June 16, 2023 Share Posted June 16, 2023 Maybe you should display the error code not just a fancy error message. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
20Ice18 Posted June 16, 2023 Author Share Posted June 16, 2023 yea the error code is 3 Func _EzMySql_Exec($querystring) Local $execError, $iNextResult If $sEzMySql_Result Then _EzMySql_QueryFinalize() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) If Not $querystring Then Return SetError(5, 0, 0) $querystringlength = StringLen($querystring) _EzMySql_MultiLine() Local $query = DllCall($hEzMySql_Dll, "int", "mysql_real_query", "ptr", $hEzMySql_Ptr, "str", $querystring, "ulong", $querystringlength) If @error Then $execError = 2 If _EzMySql_ErrMsg() Then Return SetError(3, 0, 0) Do Local $result = DllCall($hEzMySql_Dll, "ptr", "mysql_store_result", "ptr", $hEzMySql_Ptr) $sEzMySql_Result = $result[0] _EzMySql_QueryFinalize() $iNextResult = DllCall($hEzMySql_Dll, "int", "mysql_next_result", "ptr", $hEzMySql_Ptr) Until $iNextResult[0] <> 0 _EzMySql_MultiLine(False) If $execError Then Return SetError($execError, 0, 0) Return 1 EndFunc ;==>_EzMySql_Exec which was set by _EzMySql_ErrMsg() according to this I suppose and that function is here but i don't see any 3s ; #FUNCTION# ==================================================================================================================== ; Name...........: _EzMySql_ErrMsg ; Description ...: returns a null-terminated string containing the error message for the most recen function that failed. ; Syntax.........: _EzMySql_ErrMsg() ; Parameters ....: None ; Return values .: On Success - A null-terminated character string that describes the error. An empty string if no error occurred ; Return values .: On Failure - returns 0 and @error value ; 1 - A MySQL struct does not exist ; 2 - Dll Call failed ; Author ........: Yoriz ; Based on script: MySQL UDFs working with libmysql.dll by Prog@ndy ; =============================================================================================================================== Func _EzMySql_ErrMsg() If Not $hEzMySql_Ptr Then Return SetError(1, 0, 0) Local $errors = DllCall($hEzMySql_Dll, "str", "mysql_error", "ptr", $hEzMySql_Ptr) If @error Then Return SetError(2, 0, 0) If $errors[0] Then Return $errors[0] Return 0 EndFunc ;==>_EzMySql_ErrMsg ❤️ Link to comment Share on other sites More sharing options...
Solution Andreik Posted June 16, 2023 Solution Share Posted June 16, 2023 First of all display in console your query and manually execute it in phpmyadmin or whatever are you using for mysql to be sure your query doesn't have any funny characters that should be escaped. Then check if DllCall() fails in _EzMySql_ErrMsg() or the function just returns fine and what is the returned value. 20Ice18 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
20Ice18 Posted June 16, 2023 Author Share Posted June 16, 2023 (edited) 20 minutes ago, Andreik said: First of all display in console your query and manually execute it in phpmyadmin or whatever are you using for mysql to be sure your query doesn't have any funny characters that should be escaped. Then check if DllCall() fails in _EzMySql_ErrMsg() or the function just returns fine and what is the returned value. My data was too long for the column, I had to Modify Column in Table first. Thank youu ❤️ @Andreik I should probably take a break from coding today XD Edited June 16, 2023 by 20Ice18 ❤️ Link to comment Share on other sites More sharing options...
Andreik Posted June 16, 2023 Share Posted June 16, 2023 Take a deep breath and chill, debugging is part of life for programmers. 20Ice18 1 When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now