[php-src] Issue #9972: [Bug] in mysqli_query() returns nothing and gets stucked when the database return error
| From: | SathishKumarA2001 | Date: | Fri, 18 Nov 2022 17:21:23 +0000 |
| Subject: | [php-src] Issue #9972: [Bug] in mysqli_query() returns nothing and gets stucked when the database return error | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242852@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9972
Author: SathishKumarA2001
### Description
The following code:
```php
<?php
function get_db_connection() {
global $db_conn;
global $db_servername;
global $db_username;
global $db_password;
global $db_name;
if($db_conn != NULL) {
return $db_conn;
}else{
//create connection
$db_conn = mysqli_connect($db_servername,$db_username,$db_password,$db_name);
//check connection
if (!$db_conn) {
die('connection failed: ' .mysqli_connect_error());
}else{
return $db_conn;
}
}
}
function do_signup($username,$email,$image,$password){
$query = "insert into users (name,email,password,image)
values('$username','$email','$password','$image');";
$db_conn = get_db_connection();
$result = mysqli_query($db_conn,$query); // stucked line, won't go below this line, the flow
has been stopped here
print_r($result);
die("waiting...");
if ($result === false) {
printf("error: %s\n", mysqli_error($db_conn));
return 0;
}
return 1;
}
```
Resulted in this output:
```
Nothing is resulted, gets stucked in mysqli_query()
```
But I expected this output instead:
```
something if it is success return TRUE or else FALSE, the flow has been stopped.
```
### PHP Version
PHP 8.1.2
### Operating System
Ubuntu 22.04