Part of this question I want to solve here: What is the maximum length of the error message (or warning) after the execution of the request?

This is the third field Message .

mysql> select capid from cap where (seklect bla); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bla)' at line 1 mysql> show warnings; +-------+------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ | Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'bla)' at line 1 | +-------+------+--------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.01 sec) mysql> 

I found out experimentally that such a request:

 $q = 'update usopt set usname=? set usplace=? set usadlog=? set uslife=? set showfr=? set sendpm=? where uid_usopt=?'; 

gives this error (it is NOT cropped! screenshot in confirmation) error message The fact that I wanted to do an update is not the first time for me. And I constantly confuse OR AND, and then for half an hour or half a day I cannot understand why the code does not work as it should.

But it gives such a function.

 echo (mysqli_error($ddb)); 

At the same time, such a request is made in the console:

 ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? set usplace=? set usadlog=? set uslife=? set showfr=? set sendpm=? where uid_u' at line 1 

And show warnings gives this:

 mysql> show warnings; +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Level | Code | Message | +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Error | 1064 | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? set usplace=? set usadlog=? set uslife=? set showfr=? set sendpm=? where uid_u' at line 1 | +-------+------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (0.00 sec) 

I think that 226 is the maximum of characters in the description of the error.

The question has not yet been completely resolved, but the solution is close. There was an assumption that there is some parameter that affects the length of the message, but they wrote below that it is not.

    1 answer 1

    A complete list of messages can be found in MySQL source codes . Taking into account the fact that some of the fields may include SQL fragments, the names of tables and fields, it can be said that the number of characters in this line is between 256 (2 ^ 8) and 65536 (2 ^ 16).

    • the fact of the matter is that it is impossible to guess the length of this message :( It is necessary to roughly calculate the longest request in the code and the number of characters to it + to him. (?) - root_x
    • @root_xPovierennyy Request can change over time, it is better to leave a hefty stock. - cheops
    • Well, so I wrote "+ some number of characters." The main thing is to find a balance so as not to cut the error. - root_x Povierennyy
    • NEETET I have a vague doubt. I think that in php there is a certain parameter that limits this length. Why do I think so I wrote in the question. - root_x Povierennyy
    • there is no such parameter, mysql-parser produces errors like this. just by running from the console or from the script you get different errors, and it gives them out like this because the optimizer rewrote the query - strangeqargo