|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-01-30 14:45 UTC] giovanni dot cupini at tin dot it
Description:
------------
Msqli extension work correctly in procedural mode but NON work correctly width mode OOP. EXEMPLE CODE:
<?php
// FIRST CONNECTION Procedural
$mysqli = mysqli_connect("error", "root", "dolfomon", "test"); // HOST (1)"localhost" (2)"error"
// ===================INFO MySqli & PHP ==============
echo 'Current PHP version: ' . phpversion() . "<br>";
echo 'MySqli Client library version: ' . mysqli_get_client_version() . "<br>";
echo 'MySqli Server version: ' . mysqli_get_client_version() . "<br>";
//===============================================
if (mysqli_connect_errno($mysqli)) {
echo "Connection failed (mode PROC) MySQL: " . mysqli_connect_error() ."<br>";
}
echo "<br>";
$res = mysqli_query($mysqli, "SELECT 'Ok connection (PROC) width test ' AS _msg FROM DUAL");
$row = mysqli_fetch_assoc($res);
echo $row['_msg'];
// second CONNECTION OOP
$my = new mysqli("error", "root", "dolfomon", "test"); // HOST (3)"localhost" (4)"error"
// print_r($my); echo "<br>"; // (5) comment (6) active statement
echo "<br>";
if ($my->connect_errno) {
echo "Connection failed (mode OOP) MySQL: " . $my->connect_error;
}
echo "<br>";
$res = $my->query("SELECT 'Ok connection (OOP) width test' AS _msg FROM DUAL");
$row = $res->fetch_assoc();
echo $row['_msg'];
?>
Test script:
---------------
COMMENT:
if HOST option (1) and HOST option (3) and option (5) all OK it will output:
--------------------------------------
Current PHP version: 5.4.4-11
MySqli Client library version: 50528
MySqli Server version: 50528
Ok connection (PROC) width test
Ok connection (OOP) width test
--------------------------------------
If HOST option (2) and HOST option (4) and option (6) all OK it will output:
-----------------------------------------------------------------------------
Current PHP version: 5.4.4-11
MySqli Client library version: 50528
MySqli Server version: 50528
Connection failed (mode PROC) MySQL: Unknown MySQL server host 'error' (20)
mysqli Object ( [affected_rows] => [client_info] => [client_version] => 50528 [connect_errno] => 2005 [connect_error] => Unknown MySQL server host 'error' (20) [errno] => [error] => [error_list] => [field_count] => [host_info] => [info] => [insert_id] => [server_info] => [server_version] => [stat] => [sqlstate] => [protocol_version] => [thread_id] => [warning_count] => )
Connection failed (mode OOP) MySQL: Unknown MySQL server host 'error' (20)
----------------------------------------------------------------------------
if HOST option (2) and HOST option (4) and option (5) NOT WORK will output:
-----------------------------------------------------------------------------
Host HTTP error 500
-----------------------------------------------------------------------------
if HOST option (2) and HOST option (3) and option (5) Procedural work OK will output:
-------------------------------------------------------------------------------
Current PHP version: 5.4.4-11
MySqli Client library version: 50528
MySqli Server version: 50528
Connection failed (mode PROC) MySQL: Unknown MySQL server host 'error' (20)
Ok connection (OOP) width test
---------------------------------------------------------------------------
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
I fail to parse this report, could someone help me understanding what's requested? All I get is that there is a combination which gives an internal server error from the webserver: if HOST option (2) and HOST option (4) and option (5) NOT WORK will output: ----------------------------------------------------------------------------- Host HTTP error 500 As far as I understand this is equivalent to the below sequence in which all error messages are ignored, no proper error handling is done, a fatal error gets thrown and script execution stops. Potentially giving 500 through webserver... /* Throws E_WARNING */ $mysqli = mysqli_connect("error", "root", "dolfomon", "test"); var_dump(mysqli_connect_errno($mysqli)); /* Throws E_WARNING */ $res = mysqli_query($mysqli, "SELECT 'Ok connection (PROC) width test ' AS _msg FROM DUAL"); /* Throws E_FATAL */ $row = mysqli_fetch_assoc($res); Due to the E_FATAL the OOP variant should never be executed. Sorry, I fail to undertstand the report.