mgaman Posted October 5, 2022 Share Posted October 5, 2022 Take , for example, a case of mysqli_connect with incorrect paramaters. On a physical machine it returns FALSE and go you to mysqli_connect_error for details. The same code on a virtual machine throws an exception. Try the following in both environments <?php // fill in your values $link = mysqli_connect($dbhost, $dbusername, $dbpassword,$dbname); if ($link->connect_error) { die('not connected: '.mysqli_connect_error()); } I cannot be the first to trip up on this yet cannot find any discussions/documentation. Any insight anyone? Quote Link to comment https://forums.phpfreaks.com/topic/315400-mysqli-behaves-differently-on-virtual-and-physical-machines/ Share on other sites More sharing options...
Barand Posted October 5, 2022 Share Posted October 5, 2022 Try this code in both environments <?php mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); $link = mysqli_connect($dbhost, $dbusername, $dbpassword,$dbname); ?> Quote Link to comment https://forums.phpfreaks.com/topic/315400-mysqli-behaves-differently-on-virtual-and-physical-machines/#findComment-1601347 Share on other sites More sharing options...
mac_gyver Posted October 5, 2022 Share Posted October 5, 2022 what are the php versions of these two systems? the exception is due to php8's revamped error responses, where a number of previous warnings now produce exceptions. also, the procedural usage of mysqli_connect(), combined with the OOP usage of $link->connect_error is incorrect in any case, since mysqli_connect() returns a false value upon failure. Quote Link to comment https://forums.phpfreaks.com/topic/315400-mysqli-behaves-differently-on-virtual-and-physical-machines/#findComment-1601348 Share on other sites More sharing options...
mgaman Posted October 20, 2022 Author Share Posted October 20, 2022 I'm using PHP V7.0 on the physical machine and V8.1 on the virtual machines, so you have hit on the reason. Thanks for the response. Quote Link to comment https://forums.phpfreaks.com/topic/315400-mysqli-behaves-differently-on-virtual-and-physical-machines/#findComment-1601804 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.