// Run SQL command
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'file=' . basename($file) . ',line=' . $line . ',sql=' . $GLOBALS['last_sql']);
$result = mysqli_query(getSqlLink(), $GLOBALS['last_sql'])
- or sqlError($file, $line, 'file='. basename($file) . ',line=' . $line . ':mysqli_error()=' . mysqli_error() . ',last_query=' . $GLOBALS['last_sql']);
+ or sqlError($file, $line, 'file='. basename($file) . ',line=' . $line . ':mysqli_error()=' . mysqli_error(getSqlLink()) . ',last_query=' . $GLOBALS['last_sql']);
//* DEBUG: */ logDebugMessage($file, $line, 'sql=' . $GLOBALS['last_sql'] . ',affected=' . sqlAffectedRows() . ',numRows='.(isValidSqlLink($result) ? sqlNumRows($result) : gettype($result)));
// Calculate query time
// SQL connect
function sqlConnectToDatabase ($host, $login, $password, $file, $line) {
// Try to connect
- $linkResource = mysqli_connect($host, $login, $password) or sqlError($file, $line, mysqli_error());
+ $linkResource = mysqli_connect($host, $login, $password) or sqlError($file, $line, mysqli_error(getSqlLink()));
// Set the link resource
if ($linkResource instanceof mysqli) {
// Return the result
//* DEBUG: */ logDebugMessage($file . ':' . __FUNCTION__, $line . ':' . __LINE__, 'Selecting database ' . $dbName);
- return mysqli_select_db(getSqlLink(), $dbName) or sqlError($file, $line, mysqli_error());
+ return mysqli_select_db(getSqlLink(), $dbName) or sqlError($file, $line, mysqli_error(getSqlLink()));
}
// SQL close link
} // END - if
// Close database link and forget the link
- $close = mysqli_close(getSqlLink()) or sqlError($file . ':' . __FUNCTION__, $line . ':' . __LINE__, mysqli_error());
+ $close = mysqli_close(getSqlLink()) or sqlError($file . ':' . __FUNCTION__, $line . ':' . __LINE__, mysqli_error(getSqlLink()));
// Close link in this layer
unsetSqlLinkUp(__FUNCTION__, __LINE__);