-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
real_escape_string not accept numbers #5639
Comments
Please provide the complete call stack. You need to modify the code so that when the value is an integer, you do not use Mysqli::real_escape_string(). This function only accepts string parameters and cannot handle integers. |
The original mysql_real_escape_string works with numbers:
But with the Swoole pool connection not:
The first echo shows '456', but the second throws a fatal error. |
@LaySoft This is because strict mode is enabled in the Swoole code. Try adding Please refer to the PHP documentation for the mysqli_real_escape_string function: https://www.php.net/manual/en/mysqli.real-escape-string.php. The first parameter must be of type In non-strict mode, PHP automatically performs type conversion, so no error is thrown. However, this results in an ineffective call since applying mysqli_real_escape_string to a number is meaningless. |
Thank you, that makes sense! |
If real_escape_string method using with connection handler provided by MysqliPool, and the method parameter is number, the following error occured:
Fatal error: Uncaught TypeError: mysqli::real_escape_string(): Argument #1 ($string) must be of type string, int given in @swoole/library/core/Database/MysqliProxy.php:50
The text was updated successfully, but these errors were encountered: