mysqli signal to php error

✔ Recommended Answer

The real problem in the code above is that variables are not Declared. so i changed this Select statements to Declare statements.

BEGINDECLARE lastActionID INT unsigned;DECLARE lastTransferID INT unsigned;DECLARE retval INT unsigned;    START TRANSACTION;        SELECT SUM(ad.Quantity) INTO retVal FROM productin pri JOIN actiondetails ad ON ad.ID=pri.ID;        IF DualOperation = 1            THEN                IF retVal>Quantity                    THEN                        INSERT INTO Actions (EmployerID, StorehouseID, `Date`)                            VALUES (EmployerID, StoreFromID, CURDATE());                        SET lastActionID = (SELECT ID FROM Actions ORDER BY ID DESC LIMIT 1);                        INSERT INTO ProductTransfer (ID, TransferType)                            VALUES (lastActionID, 0);                        INSERT INTO ActionDetails (ID, ProductID, Quantity)                            VALUES (lastActionID, ProductID, Quantity);                        SET lastTransferID = (SELECT ID FROM ProductTransfer ORDER BY ID DESC LIMIT 1);                        INSERT INTO Actions (EmployerID, StorehouseID, `Date`) VALUES (EmployerID, StoreToID, CURDATE());                        SET lastActionID = (SELECT ID FROM Actions ORDER BY ID DESC LIMIT 1);                        INSERT INTO ProductTransfer (ID, TransferType, ParentID) VALUES (lastActionID, 1, lastTransferID);                        INSERT INTO ActionDetails (ID,ProductID, Quantity)                            VALUES (lastActionID, ProductID, Quantity);                    ELSE                        SIGNAL SQLSTATE '45000'                    SET MESSAGE_TEXT = 'Not enough materials';            END IF;        ELSE                INSERT INTO Actions (EmployerID, StorehouseID, `Date`)                    VALUES (EmployerID, StoreID, CURDATE());                SET @lastActionID = (SELECT ID FROM Actions ORDER BY ID DESC LIMIT 1);                INSERT INTO ActionDetails (ID, ProductID, Quantity)                    VALUES (lastActionID, ProductID, Quantity);                IF InOrOut = 0                    THEN                        INSERT INTO ProductIn (ID, OrganizationID) values (lastActionID, NULL);                    ELSE                        IF retVal>Quantity                            THEN                                INSERT INTO ProductOut (ID, OrganizationID) values (lastActionID, NULL);                            ELSE                                SIGNAL SQLSTATE '45000'                            SET MESSAGE_TEXT = 'Not enough materials';                    END IF;                END IF;        END IF;    COMMIT;    select true;END

now i am able to get $mysqli->sqlstate 45000 and check whether there was an error in procedure

Source: stackoverflow.com

Answered By: M.G.

Method #2

The "mysqli signal to php error" error message is not specific enough to provide a clear answer. However, here are some general steps you can take to troubleshoot the issue:

  1. Check your PHP error log: The error log can provide more detailed information about the error. You can usually find the error log file location in your php.ini file or by running the phpinfo() function.

  2. Check your MySQL server error log: If the error is related to your MySQL database, then checking the error log for your MySQL server might provide more details about the error.

  3. Check your code: Look through your code to make sure you are using the correct syntax for connecting to your MySQL database using the mysqli extension. Check that you are passing the correct arguments to the mysqli functions.

  4. Test your MySQL connection: Try running a simple test script to connect to your MySQL database using the mysqli extension. If the test script works, then the issue might be with your application code.

  5. Upgrade your PHP version and/or mysqli extension: If you are running an older version of PHP or mysqli, upgrading to a newer version might resolve the issue.

  6. Seek help from online communities: If none of the above steps resolve the issue, seek help from online communities such as Stack Overflow, PHP.net forums or GitHub discussions, where experienced developers can help you diagnose and solve the issue.

Comments

Most Popular

PhpStorm, return value is expected to be 'A', 'object' returned

Remove Unicode Zero Width Space PHP

Laravel file upload returns forbidden 403, file permission is 700 not 755