We help IT Professionals succeed at work.

MySQL Database not found

Hello,
We have recently upgraded to php 7.4 for our intranet on windows 10 and we are getting a database not found error. All the files for the database are there and should be in working order. Everything worked fine on 7.3 with Windows 7.The log files do not give any hints as to why the database isn't being found. Does anyone know of anything that would have changed between versions?

Thanks
Comment
Watch Question

Please check the name of the database and password.  Then make sure the connection script is correct.  You can also post the connection script sans username / password
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You have to check whether the pop 7.4 incorporates the support for SQL access or whether you need to locate some dlls on which it telies.

Double check whether you specified the db name correctly.

Check release notes and see whether they impact the SQL version in use.

My question often in such a case, why did you go to 7.4 ?

Usually version transitions should be carefully planned out to allow testing.
Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer
CERTIFIED EXPERT

Commented:
The log files do not give any hints as to why the database isn't being found

if it's really hard for the debugging in existing codes, why not create a custom php page to test the database connection to drill down the issues?
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Part of the php connection process should point to where the issue is.

Author

Commented:
I don't think the original post was not detailed enough so let me try again. We are moving from a previous version of Wamp that is many years old. Moving to Windows 10 with the current version of Wamp. I will post specific versions below. Originally this was setup under contract with a private developer. This developer is no longer available. From what I can see and tell (not a software/web person) it looks like some of the functions being called for are deprecated and that is probably causing some of the issues. In most cases for the errors replacing MySQL with MySQLi fixes the errors other than the database connection itself it seems. There are technically two different machines with identical symptoms.

Old:
WAMP Server 2.2
Apache 2.2.2
PHP 5.3.13
MySQL 5.5.24

New:
WAMP Server 3.2
Apache 2.4.1
PHP 7.3.12
MySQL 5.7.28

Appreciate the input, thank you.
MySQL.pdf
users.png
Annotation-2020-02-15-070838.png

Author

Commented:

Here is the current error I am seeing.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
the user you are using, exist as @localhost and @% anywhere, do they have the same password?
Are you using the password for @localhost?

Best, add a specific newuser with rights to DB and try it.
Grant the newuser select, insert, update,delete,.. on this database and see..

Possibly the DB auth..

Author

Commented:

I reset both passwords just to confirm. No change. I added a new user. No change. How would you go about testing the DB auth?

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
do you have MySQL workbench installed?
Login using one of the users.

Reset, did you reset them to the same password.
Are you connecting tothe local?
Is the local configured to run over TCP?

Netstat -an | find /I ":3306" is it bound to localhost or any?
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Use workbench to login as the same user you are using within the php.

Are you using the same code from the php5 in php7 setup?
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
do you test whether $connection is defined when passing it? If you iss and pass as undefined variable.

Author

Commented:

C:\>netstat -an | find /I ":3306"
  TCP    0.0.0.0:3306           0.0.0.0:0              LISTENING
  TCP    [::]:3306              [::]:0                 LISTENING


I have tried localhost and the ipv4 address. I do not have workbench installed. I will work on that. Same code for php5 as in php7. I switched wamp to php5 and the same error occurs.


" do you test whether $connection is defined when passing it? If you iss and pass as undefined variable."

*** I don't know how to do this.


Both users were reset to the same password.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You would test if exists $connection

What you posted, PDF is mysqli function from php ?

Your mhp has includes? Do you load/reference the connections.xml file?

Author

Commented:

Using Work Bench it didn't look like the user existed. I added the user and now I am getting a new error. I also included the connections.php and kernel.php file.



<?php
/* Version 1.0.1 - 10:16 PM 26/07/2009 */
/* 1.0.1 - Added SQL class */

session_start();
header("Cache-control: private");

error_reporting(E_ALL);

require_once("base/vrk_classes/VRKMessage.php");
require_once("base/vrk_classes/Connections.php");
require_once("base/vrk_classes/SQLMaps.php");
require_once("base/vrk_classes/Parser.php");
require_once("base/vrk_classes/Validator.php");
require_once("base/vrk_classes/JSCompiler.php");
require_once("base/vrk_classes/Datasource.php");
require_once("base/vrk_classes/LoopStack.php");
require_once("base/vrk_classes/SQL.php");

require_once("base/vrk_modules/Display.php");
require_once("base/vrk_modules/MySQL.php");

require_once("base/modules/Array.php");
require_once("base/modules/String.php");

require_once("base/vrk_abstracts/ExtTag.php");

require_once("base/functions.php");

global $vrk_jsc
	, $vrk_connections
	, $vrk_sql_maps
	, $vrk_parser
	, $vrk_validator
	, $vrk_message;

$vrk_jsc = new JSCompiler();
$vrk_connections = new Connections();
$vrk_sql_maps = new SQLMaps();
$vrk_parser = new Parser();
$vrk_validator = new Validator();
$vrk_message = new VRKMessage();

if (file_exists("config/loader.php")) require_once("config/loader.php");
include_once("config/connections.php");
?>


<?php
/* Version 1.0.0 - 8:54 PM 05/07/2009 */

get_parsed_struct(file_get_contents(dirname(__FILE__)."/connections.xml"), $connection_data);

for ($i = 0; $i < count($connection_data); $i++)
{
	if ($connection_data[$i]["tag"] == "connection" && $connection_data[$i]["type"] == "open")
	{
		$vrk_connections->create_connection($connection_data[$i]["attributes"]["name"]);
	}
	else if ($connection_data[$i]["tag"] != "connections" && $connection_data[$i]["type"] == "complete")
	{
		$vrk_connections->add_connection_tag($connection_data[$i]["tag"], $connection_data[$i]["value"]);
	}
}
?>

Author

Commented:

Final update for the evening - only getting a single error now after reading the error on the following line: 


if (!mysqli_select_db($vrk_connections->cur_db, $connection["dbname"]))


Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.



Am I missing anything else?

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Change the connection to localhost or 127.0.0.1

The user does not have rights to connect .......based on your user list, you on,y gave localhost based users.

Author

Commented:

Tried to change the host to localhost or 127.0.0.1 but it fails. Getting access denied still. Tried to change the user to any host and the same error occurs. 

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
are you on the same system as the mysql server, or are you connecting remotely?

What is the platform/package of the PHP code?
The code is from 2009.

Is this your proprietary code, or you are using a package and see whether there is a newer version.

To determine what is going on,
The Db selection has to be passed the $connection  that is established to the server.

Author

Commented:

Yes - same computer.


Custom code that we paid a private developer to do. 2009 sounds about right.


It is proprietary. 


I am not sure how to do this. Does EE still allow to hire experts? I can provide the full code and a blank database. The Wamp installation is a basic install with nothing additional. We do use AD authentication but I am sure that could be bypassed to test. 

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
at the end of your mysql.php (the MySQL.pdf)
The mysqli_select_db has changed, flip the two
Your current has mysqli_select_db("databasename",connection_to_database_server)

While the new mysqli_select_db uses the following scheme
mysqli_select_db(connection_to_database_server,"databasename")

This should fix the issue confirming a database can be selected.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Change the following

if (!mysqli_select_db($connection["dbname"], $vrk_connections->cur_db)) {
 die("Error selecting database '".$connection["dbname"]."' on connection
 '".$connection_name."'. Ensure you have the correct database name.");
  }

Open in new window


 With

 
if (!mysqli_select_db($vrk_connections->cur_db, $connection["dbname"],)){
 die("Error selecting database '".$connection["dbname"]."' on connection
 '".$connection_name."'. Ensure you have the correct database name.");
  }

Open in new window


 This is at the bottom of you MySQL.pdf document.

Lines 196-199

Author

Commented:

Still getting the error. Attached new MySQL file with revised code and error.

<?php
/* Version 1.0.0 - 1:12 PM 25/07/2009 */

function mysqli_truncate_table($connection, $table)
{
	mysqli_initialize($connection);
	mysqli_query("TRUNCATE TABLE ".mysqli_real_escape_string($table));
}

function mysqli_count_rows($connection, $table, $condition = "1=1")
{
	mysqli_initialize($connection);
	$res = mysqli_query("SELECT * from ".mysqli_real_escape_string($table)." WHERE $condition");
	if ($res) return mysqli_num_rows($res);
	else return 0;
}

function mysqli_optimize($connection, $table)
{
	mysqli_initialize($connection);
	return mysqli_query("OPTIMIZE TABLE ".mysqli_real_escape_string($table));
}

function mysqli_delete_row($connection, $table, $condition)
{
	mysqli_initialize($connection);

	$result = mysqli_query("DELETE from ".mysqli_real_escape_string($table)." WHERE $condition");
	return $result;
}

function mysqli_update_row($connection, $table, $values, $condition)
{
	mysqli_initialize($connection);

	$i = 0;
	$update_values = "";
	foreach ($values as $key => $value)
	{
		($i != 0) ? $update_values.="," : $i = 1;
		if (strtolower(substr($value, 0, 4)) == "sql:") $update_values.= "`".mysqli_real_escape_string($key)."`=".mysqli_real_escape_string(substr($value, 4));
		else $update_values.= "`".mysqli_real_escape_string($key)."`='".mysqli_real_escape_string($value)."'";
	}

	if (mysqli_query("UPDATE ".mysqli_real_escape_string($table)." SET $update_values WHERE $condition")) return true;
	else 
	{
		echo mysqli_error();
		return false;
	}
}

function mysqli_insert_row($connection, $table, $values)
{
	mysqli_initialize($connection);

	if (isset($values[0]))
	{
		$insert_values = "'".$values[0]."'";
		for ($i = 1; $i < count($values); $i++)
		{
			if (strtolower(substr($values[$i], 0, 4)) == "sql:") $insert_values.= ",".mysqli_real_escape_string(substr($values[$i], 4));
			else $insert_values.= ",'".mysqli_real_escape_string($values[$i])."'";
		}
		$query = "INSERT INTO ".mysqli_real_escape_string($table)." VALUES ($insert_values)";
	}
	else
	{
		$table_cols = "";
		$insert_values = "";
		foreach ($values as $key => $value)
		{
			$table_cols.= ",`".mysqli_real_escape_string($key)."`";
			if (strtolower(substr($value, 0, 4)) == "sql:") $insert_values.= ",".mysqli_real_escape_string(substr($value, 4));
			else $insert_values.= ",'".mysqli_real_escape_string($value)."'";
		}
		// remove extra comma
		$table_cols = substr($table_cols, 1);
		$insert_values = substr($insert_values, 1);
		$query = "INSERT INTO ".mysqli_real_escape_string($table)." ($table_cols) VALUES ($insert_values)";
	}

	if (mysqli_query($query)) return true;
	else 
	{
		echo mysqli_error();
		return false;
	}
}

function mysqli_does_row_exist($connection, $table, $condition)
{
	mysqli_initialize($connection);

	$result = mysqli_query("SELECT * FROM ".mysqli_clean($connection, $table)." WHERE $condition");
	if ($result) return ($row = mysqli_fetch_assoc($result));
	return false;
}

function mysqli_get_field_query($connection, $field, $table, $condition = "", $offset = "")
{
	mysqli_initialize($connection);

	if ($condition != "") $condition = " WHERE $condition";
	if ($offset != "") $order = " OFFSET $offset";

	$result = mysqli_query("SELECT `$field` FROM `".mysqli_real_escape_string($table)."`$condition LIMIT 1$offset");
	if ($result) 
	{
		$row = mysqli_fetch_assoc($result);
		return $row[$field];
	}
	return "";
}

function mysqli_clean($connection, $val)
{
	mysqli_initialize($connection);
	return mysqli_real_escape_string($val);
}

function mysqli_single_row_query($connection, $sql_query, $offset = "")
{
	mysqli_initialize($connection);

	if ($offset != "") $order = " OFFSET $offset";
	
	$result = mysqli_query($sql_query." LIMIT 1$offset");
	if ($result) return mysqli_fetch_assoc($result);
	return "";
}

function mysqli_multi_row_query($connection, $sql_query, $order = "", $limit = "", $offset = "")
{
	mysqli_initialize($connection);

	if (isset($_GET["vrksort"]) && $_GET["vrksort"] != "")
	{
		if (substr($_GET["vrksort"], 0, 2) == "d:") $order = " ORDER BY ".substr($_GET["vrksort"], 2)." DESC";
		else $order = " ORDER BY ".$_GET["vrksort"];
	}
	else if ($order != "") $order = " ORDER BY $order";

	if (isset($_GET["vrklimit"]) && $_GET["vrklimit"] != "") $limit = " LIMIT ".$_GET["vrklimit"];
	else if ($limit != "") $limit = " LIMIT $limit";
	
	if (isset($_GET["vrkoffset"]) && $_GET["vrkoffset"] != "") $offset = " OFFSET ".$_GET["vrkoffset"];
	else if ($offset != "") $offset = " OFFSET $offset";

	$result = mysqli_query($sql_query.$order.$limit.$offset);

	$res_array = array();
	if ($result) while ($row = mysqli_fetch_assoc($result)) $res_array[count($res_array)] = $row;
	else echo mysqli_error();
	if (!isset($res_array)) return "";
	else return $res_array;
}

function mysqli_last_id()
{
	return mysqli_insert_id();
}

function mysqli_found_rows()
{
	$result = mysqli_query("SELECT FOUND_ROWS()");
	if ($result)
	{
		$row = mysqli_fetch_assoc($result);
	}
	else
	{
		echo mysqli_error();
	}
	
	if (!isset($row))
	{
		return 0;
	}
	else
	{
		return $row["FOUND_ROWS()"];
	}
}

function mysqli_initialize($connection_name)
{
	global $vrk_connections;
	$connection = $vrk_connections->get_connection($connection_name);
	$vrk_connections->cur_db = mysqli_connect($connection["dbhost"],
	$connection["dbuser"], $connection["dbpassword"]);
	if (!$vrk_connections->cur_db)
	{
		die("Unable to connect to host. Ensure you have the correct connection information.");
	}

	/* if (!mysqli_select_db($connection["dbname"], $vrk_connections->cur_db))
	{
		die("Error selecting database '".$connection["dbname"]."' on connection '".$connection_name."'. Ensure you have the correct database name.");
	} */
	if (!mysqli_select_db($vrk_connections->cur_db, $connection["dbname"],))
	{
		die("Error selecting database '".$connection["dbname"]."' on connection '".$connection_name."'. Ensure you have the correct database name.");
	}
}
?>
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Now, you can connect, this error deals whether your connection is still present.

The issue is that at sone point, you gave the mysqli_initialize called and the connection to the DB is not present.

See line194

I do not see a point of defining $connection=$vrk....
But then continue using $vrk....

The code. Is for php 5 while you are now on php 7

ypu possibly need to add an else to the connection being missing, to reinitialize it by effectively closing $vrk_connections->cur_db


In the initialize section it defines a connection, but the connection dies without being reinitialized

Author

Commented:

If only I knew how to code PHP (lol). Any way you can re-write the code for me to what it should be?

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Look at the top of the image you posted, it reports that it is trying to access as a username@localhost versus the xml file where you had it connecting to 192.168.x.x IP
which would have made the error as username@192.168.x.x...

Scan the file to see whether you have other connections.xml files.
the parametrer get_parsed_struct(file_get_contents(dirname(__FILE__)."/connections.xml"), $connection_data);

have to think through how to adjust the lines 189-194 that deal with test whether a connection is present, and establish if not present,
all your info seems to be isolated to the Connections.php and the Mysql.php file since you call mysqli_initialize and the function does not check whether the connection is present. the peculiar thing there is that it assigns a local place holder, $connection, but then seems to not use it.


The other issue you may have is that the connections keep getting setup such that it reaches a point where no more connections can be made.
as they might not be properly closed.
Check the log on the mysql server to see whether it is reporting an error that number of sessions/connection being exceeded.

Author

Commented:

Changed the connection back to the IP Address. No errors other than the database error now. No errors in MySQL. PHP was logging this but is now gone with the change:


[16-Feb-2020 18:25:25 UTC] PHP Warning:  mysqli_connect(): (HY000/1045): Access denied for user 'installedsales'@'localhost' (using password: YES) in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 191 
[16-Feb-2020 18:25:25 UTC] PHP Stack trace: 
[16-Feb-2020 18:25:25 UTC] PHP   1. {main}() C:\wamp\www\main.php:0 
[16-Feb-2020 18:25:25 UTC] PHP   2. product_type_get_all() C:\wamp\www\main.php:45 
[16-Feb-2020 18:25:25 UTC] PHP   3. mysqli_multi_row_query() C:\wamp\www\vrk\modules\Jobs.php:16 
[16-Feb-2020 18:25:25 UTC] PHP   4. mysqli_initialize() C:\wamp\www\vrk\base\vrk_modules\MySQL.php:135 
[16-Feb-2020 18:25:25 UTC] PHP   5. mysqli_connect() C:\wamp\www\vrk\base\vrk_modules\MySQL.php:191


There is only one reference to connections.xml. There are two connection.php files in different folders:

<?php
/* Version 1.0.0 - 8:54 PM 05/07/2009 */

get_parsed_struct(file_get_contents(dirname(__FILE__)."/connections.xml"), $connection_data);

for ($i = 0; $i < count($connection_data); $i++)
{
	if ($connection_data[$i]["tag"] == "connection" && $connection_data[$i]["type"] == "open")
	{
		$vrk_connections->create_connection($connection_data[$i]["attributes"]["name"]);
	}
	else if ($connection_data[$i]["tag"] != "connections" && $connection_data[$i]["type"] == "complete")
	{
		$vrk_connections->add_connection_tag($connection_data[$i]["tag"], $connection_data[$i]["value"]);
	}
}
?>
<?php
/* Version 1.0.1 - 8:55 PM 05/07/2009 */
/* 1.0.1 - remove cur_db variable as it is no longer needed */

class Connections
{
	var $connections;
	var $_last_connection;
	
	function __construct()
	{
		$connections = array();
	}

	function get_connection($name)
	{
		return $this->connections[$name];
	}

	function create_connection($name)
	{
		$this->connections[$name] = array();
		$this->_last_connection = &$this->connections[$name];
	}

	function add_connection_tag($tag, $value)
	{
		$this->_last_connection[$tag] = $value;
	}
}
?>
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
When I ask a question, it is for the purpose to work things out, it is not a suggestion to make a change.
If your connections.xml has 192.168.0.225 leave it as is.
The error you are getting might be from a different page you accessed.

Please attach the MySQL.php and the Connections.php

Author

Commented:

I apologize - I meant to set it back and didn't.


// connections.php - in the same directory as connections.xml
<?php
/* Version 1.0.0 - 8:54 PM 05/07/2009 */

get_parsed_struct(file_get_contents(dirname(__FILE__)."/connections.xml"), $connection_data);

for ($i = 0; $i < count($connection_data); $i++)
{
	if ($connection_data[$i]["tag"] == "connection" && $connection_data[$i]["type"] == "open")
	{
		$vrk_connections->create_connection($connection_data[$i]["attributes"]["name"]);
	}
	else if ($connection_data[$i]["tag"] != "connections" && $connection_data[$i]["type"] == "complete")
	{
		$vrk_connections->add_connection_tag($connection_data[$i]["tag"], $connection_data[$i]["value"]);
	}
}
?>
// MySQL.php
<?php
/* Version 1.0.0 - 1:12 PM 25/07/2009 */

function mysqli_truncate_table($connection, $table)
{
	mysqli_initialize($connection);
	mysqli_query("TRUNCATE TABLE ".mysqli_real_escape_string($table));
}

function mysqli_count_rows($connection, $table, $condition = "1=1")
{
	mysqli_initialize($connection);
	$res = mysqli_query("SELECT * from ".mysqli_real_escape_string($table)." WHERE $condition");
	if ($res) return mysqli_num_rows($res);
	else return 0;
}

function mysqli_optimize($connection, $table)
{
	mysqli_initialize($connection);
	return mysqli_query("OPTIMIZE TABLE ".mysqli_real_escape_string($table));
}

function mysqli_delete_row($connection, $table, $condition)
{
	mysqli_initialize($connection);

	$result = mysqli_query("DELETE from ".mysqli_real_escape_string($table)." WHERE $condition");
	return $result;
}

function mysqli_update_row($connection, $table, $values, $condition)
{
	mysqli_initialize($connection);

	$i = 0;
	$update_values = "";
	foreach ($values as $key => $value)
	{
		($i != 0) ? $update_values.="," : $i = 1;
		if (strtolower(substr($value, 0, 4)) == "sql:") $update_values.= "`".mysqli_real_escape_string($key)."`=".mysqli_real_escape_string(substr($value, 4));
		else $update_values.= "`".mysqli_real_escape_string($key)."`='".mysqli_real_escape_string($value)."'";
	}

	if (mysqli_query("UPDATE ".mysqli_real_escape_string($table)." SET $update_values WHERE $condition")) return true;
	else 
	{
		echo mysqli_error();
		return false;
	}
}

function mysqli_insert_row($connection, $table, $values)
{
	mysqli_initialize($connection);

	if (isset($values[0]))
	{
		$insert_values = "'".$values[0]."'";
		for ($i = 1; $i < count($values); $i++)
		{
			if (strtolower(substr($values[$i], 0, 4)) == "sql:") $insert_values.= ",".mysqli_real_escape_string(substr($values[$i], 4));
			else $insert_values.= ",'".mysqli_real_escape_string($values[$i])."'";
		}
		$query = "INSERT INTO ".mysqli_real_escape_string($table)." VALUES ($insert_values)";
	}
	else
	{
		$table_cols = "";
		$insert_values = "";
		foreach ($values as $key => $value)
		{
			$table_cols.= ",`".mysqli_real_escape_string($key)."`";
			if (strtolower(substr($value, 0, 4)) == "sql:") $insert_values.= ",".mysqli_real_escape_string(substr($value, 4));
			else $insert_values.= ",'".mysqli_real_escape_string($value)."'";
		}
		// remove extra comma
		$table_cols = substr($table_cols, 1);
		$insert_values = substr($insert_values, 1);
		$query = "INSERT INTO ".mysqli_real_escape_string($table)." ($table_cols) VALUES ($insert_values)";
	}

	if (mysqli_query($query)) return true;
	else 
	{
		echo mysqli_error();
		return false;
	}
}

function mysqli_does_row_exist($connection, $table, $condition)
{
	mysqli_initialize($connection);

	$result = mysqli_query("SELECT * FROM ".mysqli_clean($connection, $table)." WHERE $condition");
	if ($result) return ($row = mysqli_fetch_assoc($result));
	return false;
}

function mysqli_get_field_query($connection, $field, $table, $condition = "", $offset = "")
{
	mysqli_initialize($connection);

	if ($condition != "") $condition = " WHERE $condition";
	if ($offset != "") $order = " OFFSET $offset";

	$result = mysqli_query("SELECT `$field` FROM `".mysqli_real_escape_string($table)."`$condition LIMIT 1$offset");
	if ($result) 
	{
		$row = mysqli_fetch_assoc($result);
		return $row[$field];
	}
	return "";
}

function mysqli_clean($connection, $val)
{
	mysqli_initialize($connection);
	return mysqli_real_escape_string($val);
}

function mysqli_single_row_query($connection, $sql_query, $offset = "")
{
	mysqli_initialize($connection);

	if ($offset != "") $order = " OFFSET $offset";
	
	$result = mysqli_query($sql_query." LIMIT 1$offset");
	if ($result) return mysqli_fetch_assoc($result);
	return "";
}

function mysqli_multi_row_query($connection, $sql_query, $order = "", $limit = "", $offset = "")
{
	mysqli_initialize($connection);

	if (isset($_GET["vrksort"]) && $_GET["vrksort"] != "")
	{
		if (substr($_GET["vrksort"], 0, 2) == "d:") $order = " ORDER BY ".substr($_GET["vrksort"], 2)." DESC";
		else $order = " ORDER BY ".$_GET["vrksort"];
	}
	else if ($order != "") $order = " ORDER BY $order";

	if (isset($_GET["vrklimit"]) && $_GET["vrklimit"] != "") $limit = " LIMIT ".$_GET["vrklimit"];
	else if ($limit != "") $limit = " LIMIT $limit";
	
	if (isset($_GET["vrkoffset"]) && $_GET["vrkoffset"] != "") $offset = " OFFSET ".$_GET["vrkoffset"];
	else if ($offset != "") $offset = " OFFSET $offset";

	$result = mysqli_query($sql_query.$order.$limit.$offset);

	$res_array = array();
	if ($result) while ($row = mysqli_fetch_assoc($result)) $res_array[count($res_array)] = $row;
	else echo mysqli_error();
	if (!isset($res_array)) return "";
	else return $res_array;
}

function mysqli_last_id()
{
	return mysqli_insert_id();
}

function mysqli_found_rows()
{
	$result = mysqli_query("SELECT FOUND_ROWS()");
	if ($result)
	{
		$row = mysqli_fetch_assoc($result);
	}
	else
	{
		echo mysqli_error();
	}
	
	if (!isset($row))
	{
		return 0;
	}
	else
	{
		return $row["FOUND_ROWS()"];
	}
}

function mysqli_initialize($connection_name)
{
	global $vrk_connections;
	$connection = $vrk_connections->get_connection($connection_name);
	$vrk_connections->cur_db = mysqli_connect($connection["dbhost"],
	$connection["dbuser"], $connection["dbpassword"]);
	if (!$vrk_connections->cur_db)
	{
		die("Unable to connect to host. Ensure you have the correct connection information.");
	}

	/* if (!mysqli_select_db($connection["dbname"], $vrk_connections->cur_db))
	{
		die("Error selecting database '".$connection["dbname"]."' on connection '".$connection_name."'. Ensure you have the correct database name.");
	} */
	if (!mysqli_select_db($vrk_connections->cur_db, $connection["dbname"],))
	{
		die("Error selecting database '".$connection["dbname"]."' on connection '".$connection_name."'. Ensure you have the correct database name.");
	}
}
?>
// Connections.php
<?php
/* Version 1.0.1 - 8:55 PM 05/07/2009 */
/* 1.0.1 - remove cur_db variable as it is no longer needed */

class Connections
{
	var $connections;
	var $_last_connection;
	
	function __construct()
	{
		$connections = array();
	}

	function get_connection($name)
	{
		return $this->connections[$name];
	}

	function create_connection($name)
	{
		$this->connections[$name] = array();
		$this->_last_connection = &$this->connections[$name];
	}

	function add_connection_tag($tag, $value)
	{
		$this->_last_connection[$tag] = $value;
	}
}
?>
// connections.xml
<connections>
	<connection name="installed_sales">
		<dbname>copps_installed_sales</dbname>
		<dbuser>installedsales</dbuser>
		<dbpassword>sanitized</dbpassword>
		<dbhost>192.168.0.225</dbhost>
	</connection>
</connections>


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Backup your existing MySQL.php and replace with the one attached.

The difference on line 190 test whether a connection is already present before starting to establish a new connection. The second test is if the connection is not present, whether the establishing of the connection succeeded.

See if it makes a difference that you currently experience establish a connection and then select the DB.

Does this tool connect to other databases on the same mysql server?
question deals with mysqli_connect includes an option to specify the DB to attach deals with a situation where the dbuser, dbpasswd and dbname must be present
This will render the mysqli_select_db useless, unneeded.
MySQL.php

Author

Commented:

Only one database on the server. Here is the error message returned after changing the MySQL.php page.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
OK, slight change,

check whether $vrk_connections is defined.
MySQL.php

Author

Commented:

Updated.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
lets go back to the MySQL.php that the only modified sata was between lines 200-205.

While leave the connections.xml pointing to 192.168.0.225
Note, the example of users from phpmyadmin, the user reflects connection from localhost.

It makes no sense how it is permitted to connect.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Try the following:
Using https://www.php.net/manual/en/function.is-resource.php adn the related get_resource_type to check whether a connection is already in place before making a new connection attempt.

Currently, the code you have seemingly never closed the connection until the php processing exited out.
Usually, instead of calling mysqli_initialize, one would have had a global mysql connection, and would test it. But in this implementation, the mysqli_* related builtin functions, do not explicitly use a connection allowing for the php session..

with that said, the change is minimal in the mysqli_initialize, before making a connection attempt, added the above referenced test to see whether a connection is already in place which would mean there is no need to go through the connection establishment process.
MySQL.php

Author

Commented:

More errors.

error3.pdf

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
This is with the new mysql.php or with the original that only had the last four lines changed dealing with the mysqli_select_db?
MySQL---modified.php

Author

Commented:

I updated the MySQL.php file with the "MySQL---modified.php" and now I am getting:



( ! ) Parse error: syntax error, unexpected '}', expecting end of file in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 206


Author

Commented:

If I remove the last } it returns to this:



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined variable: vrk_connections in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 202
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21

# Time Memory Function Location
Call Stack
( ! ) Notice: Trying to get property 'cur_db' of non-object in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 202
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined variable: connection in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 202
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21

# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_select_db() expects parameter 1 to be mysqli, null given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 202
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21
4 0.0096 402088 mysqli_select_db ( ) ...\MySQL.php:202

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined variable: connection in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 204
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined variable: connection_name in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 204
1 0.0001 393656 {main}( ) ...\login.php:0
2 0.0002 393912 require_once( 'C:\wamp\www\vrk\Kernel.php' ) ...\login.php:2
3 0.0024 401456 require_once( 'C:\wamp\www\vrk\base\vrk_modules\MySQL.php' ) ...\Kernel.php:21
Error selecting database '' on connection ''. Ensure you have the correct database name.


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
There was a typo see the modified last updated, there was an extra comma (,) that did not belong in the mysqli_select_db, while switching the connection, database name, the extra comma was copied/remained.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
See what you get with the mysql.php modified ..

Attaching a Mysql using the same thing that verifies whether the connection is present, and type.
that should avoid the current error.
It tests whether the cur_db is a resources, and if it is it checks whether it is a mysql link. If the answer to both is true, it does nothing meaning, the connection is already present. else it establishes the connection.
MySQL.php

Author

Commented:

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined property: Connections::$cur_db in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 190
1 0.0002 391432 {main}( ) ...\main.php:0
2 0.0008 417936 product_type_get_all( ) ...\main.php:45
3 0.0008 417936 mysqli_multi_row_query( ) ...\Jobs.php:16
4 0.0008 417936 mysqli_initialize( ) ...\MySQL.php:136
Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Lets try the with the modified which is presumably what you have here.
changing the mysqli_select_db to use the same as your other queries without specifying a connection.

try the modified as the MySQL.php first to see what you get.
MySQL---modified.php
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Here is the mysql with the check, the connect to the DB uses the local $connection which would not be populated when the connection is present.
MySQL.php

Author

Commented:

Using the MySQL---modified I get this:

  
 ( ! ) Parse error: syntax error, unexpected '}', expecting end of file in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 206
   


Using MySQL.php I get this:

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined property: Connections::$cur_db in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 190
1 0.0005 391304 {main}( ) ...\main.php:0
2 0.0048 418768 product_type_get_all( ) ...\main.php:45
3 0.0048 418768 mysqli_multi_row_query( ) ...\Jobs.php:16
4 0.0048 418768 mysqli_initialize( ) ...\MySQL.php:136

# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 207
1 0.0005 391304 {main}( ) ...\main.php:0
2 0.0048 418768 product_type_get_all( ) ...\main.php:45
3 0.0048 418768 mysqli_multi_row_query( ) ...\Jobs.php:16
4 0.0048 418768 mysqli_initialize( ) ...\MySQL.php:136
5 0.0085 465664 mysqli_select_db ( ) ...\MySQL.php:207
Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
The extra one is on line 196, from the connection test scheme.  adjusted and attached.
MySQL---modified.php

Author

Commented:

File updated:

# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 202
1 0.0002 391304 {main}( ) ...\main.php:0
2 0.0010 417808 product_type_get_all( ) ...\main.php:45
3 0.0010 417808 mysqli_multi_row_query( ) ...\Jobs.php:16
4 0.0010 417808 mysqli_initialize( ) ...\MySQL.php:136
5 0.0017 464168 mysqli_select_db ( ) ...\MySQL.php:202
Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Are you on php 7?

Adjusted both to once again include the connection in the mysqli_select_db.
MySQL---modified.php
MySQL.php

Author

Commented:

Yes to php7 - i have tried version version 5.6 as well previously (not since I opened this question).


MySQL---modified.php

  
 Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.
   


MySQL.php

# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined property: Connections::$cur_db in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 190
1 0.0002 391304 {main}( ) ...\main.php:0
2 0.0036 418768 product_type_get_all( ) ...\main.php:45
3 0.0036 418768 mysqli_multi_row_query( ) ...\Jobs.php:16
4 0.0036 418768 mysqli_initialize( ) ...\MySQL.php:136
Error selecting database 'copps_installed_sales' on connection 'installed_sales'. Ensure you have the correct database name.


CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Is this on the first pass, or subsequent links?

cur_db is the reference defined globally

You are using the "modified" not the one that does tests for pre-existing connection?

In your main.pho, do not need to see, fo you gave global $vrk_connections ?

Author

Commented:

I tried both files above ... currently it is the "MySQL.php" file. The error is from loading main.php which loads after active directory is authenticated.


<?php
require_once("vrk/Kernel.php");

if (account_is_logged_in())
{
	// everyone has access to these options
	$applications = array(array("application_url" => "new_install.php?type=install", "application_name" => "New Install Quote Request")
						, array("application_url" => "new_install.php?type=material", "application_name" => "New Material Only Quote Request"));

	$show_jobs = "none";
	
	if (!account_is_in_users_group() || count(account_get_product_types()) > 0)
	{
		$show_jobs = "table-cell";
		$applications[] = array("application_url" => "job_search.php", "application_name" => "Job Search");
	}
	
	// add job type links, if not admin
	if (!account_is_admin())
	{
		$has_prod_type = false;
		foreach (account_get_product_types() as $product_type)
		{
			if (strpos($product_type, "Manage Staff") === false)
			{
				$applications[] = array("application_url" => "job_section_menu.php?product_type=".$product_type, "application_name" => $product_type." Jobs");
				
				if (!product_type_exists($product_type))
				{
					// create product type
					product_type_create($product_type);
				}
			}
			$has_prod_type = true;
		}
		
		if ($has_prod_type)
		{
			$applications[] = array("application_url" => "jobs_completed_but_not_paid.php", "application_name" => "Jobs Completed But Not Paid For");
		}
	}
	else
	{
		// admins have access to all job types, get all job types and then add the menus
		foreach (product_type_get_all() as $product_type)
		{
			$applications[] = array("application_url" => "job_section_menu.php?product_type=".$product_type["product_type"], "application_name" => $product_type["product_type"]." Jobs");
		}
		$applications[] = array("application_url" => "jobs_completed_but_not_paid.php", "application_name" => "Jobs Completed But Not Paid For");
	}
	
	if (account_manage_staff())
	{
		$applications[] = array("application_url" => "manage_staff.php", "application_name" => "Manage Staff");
	}
	
	// if admin add admin menu options
	if (account_is_admin())
	{
		$applications[] = array("application_url" => "admin_sub_menu.php", "application_name" => "Administrator");
		$applications[] = array("application_url" => "settings.php", "application_name" => "Settings");
	}
	
	$user = account_get_logged_in_name();
	$jobs = get_calendar_jobs(account_get_product_types());
	$out_jobs = array();
	
	foreach ($jobs as $job)
	{
		if (count($out_jobs) > 0 && $out_jobs[count($out_jobs) - 1]["work_date"] == $job["work_date"])
		{
			$out_jobs[count($out_jobs) - 1]["details"].= "<a href=\"update_job.php?job_id=".$job["raw_id"]."\">Job ID: ".$job["job_id"]."</a><br />
															Customer: ".$job["customer_name"]."<br />
															Product Type: ".$job["product_type"]."<br /><br />";
		}
		else
		{
			$out_jobs[]["work_date"] = $job["work_date"];
			$out_jobs[count($out_jobs) - 1]["details"] = "<a href=\"update_job.php?job_id=".$job["raw_id"]."\">Job ID: ".$job["job_id"]."</a><br />
									Customer: ".$job["customer_name"]."<br />
									Product Type: ".$job["product_type"]."<br /><br />";
		}
	}
	
	display_html("xmls/main.xml", "xmls/template.xml");
}
else
{
	header("Location: index.php");
}
?>
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I saw from errors, that main.php calls others that then trigger the mysqli_initialize ...

The connection,$vrk_connections->cur_db passes the test.following mysqli_connect

The error is triggered

One option if you are ok with trying ISO use mysqli_connect with four parameters including the dbname elinating the test for the mysqli_select_db

Author

Commented:

I am fine with this ... 

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Here is the change that deals with settig vrk_connections->cur_db to go directly to the DB as part of the connection string in mysqli_connect.
MySQL---modified.php

Author

Commented:

I can see some of the webpage now!!! But here is the new errors. It looks like localhost and the IP are returning the same errors.



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: 192.168.0.225 in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 191
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0169 873344 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: installedsales in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0169 873344 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: XXXXXXXXXXXXXX  in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0169 873344 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: copps_installed_sales in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0169 873344 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 151
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0309 881048 mysqli_query (  ) ...\MySQL.php:151



# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 155
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0169 872992 product_type_get_all(  ) ...\main.php:45
3 0.0169 873160 mysqli_multi_row_query(  ) ...\Jobs.php:16
4 0.0338 881088 mysqli_error (  ) ...\MySQL.php:155



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: 192.168.0.225 in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 191
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0365 884552 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: installedsales in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0365 884552 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: XXXXXXXXXXXX in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0365 884552 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Notice: Undefined index: copps_installed_sales in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 192
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0365 884552 mysqli_initialize(  ) ...\MySQL.php:136



# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_query() expects at least 2 parameters, 1 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 151
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0521 886440 mysqli_query (  ) ...\MySQL.php:151



# Time Memory Function Location
Call Stack
( ! ) Warning: mysqli_error() expects exactly 1 parameter, 0 given in C:\wamp\www\vrk\base\vrk_modules\MySQL.php on line 155
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0365 882448 get_calendar_jobs(  ) ...\main.php:65
3 0.0365 884408 mysqli_multi_row_query(  ) ...\Jobs.php:406
4 0.0555 884696 mysqli_error (  ) ...\MySQL.php:155



# Time Memory Function Location
Call Stack
( ! ) Warning: Creating default object from empty value in C:\wamp\www\vrk\extensions\vrk\loop_item.Tag.php on line 26
1 0.0004 142312 {main}(  ) ...\main.php:0
2 0.0587 882864 display_html(  ) ...\main.php:85
3 0.0587 883008 Parser->build_output(  ) ...\Display.php:7
4 0.0593 919776 Parser->_parse_tags(  ) ...\Parser.php:60
5 0.0645 975976 loop_item->build(  ) ...\Parser.php:104



CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Let me try and modify mysqli_initialize function to better handle the connection handler
The purpose is to minimize changes and thus limit possible issues while achieving.

Please confirm within the MySQL log whether it is exceeding number of connections.

Author

Commented:

MySQL log is clean. I really appreciate what you have done so far.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Still looking to see what causes the errors,
Index where it exposes the parameters......

Try looking at the following, dealing with increasing the number of available connections on MySQL side.

https://www.rackaid.com/blog/mysql-connection-limits/

Author

Commented:

I added the following into the my.cnf file. It was not previously defined.


max_connections = 400
max_user_connections=200


No change unfortunately.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
iN main.php what are you passing in the first argument for the connection.  Trying to see whether the simplest approach, is to update the mysqli_ functions to include the $connection->cur_DB as a means to provide the connection link to the DB.
Though the issue, your passing the installed_sales as the connection name, versus the connection reference. while you declare crk_connections as a global variable, the initialize keeps resettings.

Some of the errors in recent post deal with mysqli_error and mysqli_query related references.
make little sense when they spit out index error with data from the connection.xml info

what is in \oop_item.Tag.php?

Author

Commented:

Hi Arnold,


I have attached n

<?php
require_once("vrk/Kernel.php");

if (account_is_logged_in())
{
	// everyone has access to these options
	$applications = array(array("application_url" => "new_install.php?type=install", "application_name" => "New Install Quote Request")
						, array("application_url" => "new_install.php?type=material", "application_name" => "New Material Only Quote Request"));

	$show_jobs = "none";
	
	if (!account_is_in_users_group() || count(account_get_product_types()) > 0)
	{
		$show_jobs = "table-cell";
		$applications[] = array("application_url" => "job_search.php", "application_name" => "Job Search");
	}
	
	// add job type links, if not admin
	if (!account_is_admin())
	{
		$has_prod_type = false;
		foreach (account_get_product_types() as $product_type)
		{
			if (strpos($product_type, "Manage Staff") === false)
			{
				$applications[] = array("application_url" => "job_section_menu.php?product_type=".$product_type, "application_name" => $product_type." Jobs");
				
				if (!product_type_exists($product_type))
				{
					// create product type
					product_type_create($product_type);
				}
			}
			$has_prod_type = true;
		}
		
		if ($has_prod_type)
		{
			$applications[] = array("application_url" => "jobs_completed_but_not_paid.php", "application_name" => "Jobs Completed But Not Paid For");
		}
	}
	else
	{
		// admins have access to all job types, get all job types and then add the menus
		foreach (product_type_get_all() as $product_type)
		{
			$applications[] = array("application_url" => "job_section_menu.php?product_type=".$product_type["product_type"], "application_name" => $product_type["product_type"]." Jobs");
		}
		$applications[] = array("application_url" => "jobs_completed_but_not_paid.php", "application_name" => "Jobs Completed But Not Paid For");
	}
	
	if (account_manage_staff())
	{
		$applications[] = array("application_url" => "manage_staff.php", "application_name" => "Manage Staff");
	}
	
	// if admin add admin menu options
	if (account_is_admin())
	{
		$applications[] = array("application_url" => "admin_sub_menu.php", "application_name" => "Administrator");
		$applications[] = array("application_url" => "settings.php", "application_name" => "Settings");
	}
	
	$user = account_get_logged_in_name();
	$jobs = get_calendar_jobs(account_get_product_types());
	$out_jobs = array();
	
	foreach ($jobs as $job)
	{
		if (count($out_jobs) > 0 && $out_jobs[count($out_jobs) - 1]["work_date"] == $job["work_date"])
		{
			$out_jobs[count($out_jobs) - 1]["details"].= "<a href=\"update_job.php?job_id=".$job["raw_id"]."\">Job ID: ".$job["job_id"]."</a><br />
															Customer: ".$job["customer_name"]."<br />
															Product Type: ".$job["product_type"]."<br /><br />";
		}
		else
		{
			$out_jobs[]["work_date"] = $job["work_date"];
			$out_jobs[count($out_jobs) - 1]["details"] = "<a href=\"update_job.php?job_id=".$job["raw_id"]."\">Job ID: ".$job["job_id"]."</a><br />
									Customer: ".$job["customer_name"]."<br />
									Product Type: ".$job["product_type"]."<br /><br />";
		}
	}
	
	display_html("xmls/main.xml", "xmls/template.xml");
}
else
{
	header("Location: index.php");
}
?>


loop_item.Tag.php

<?php
/* Version 1.0.0 - 4:22 PM 18/07/2009 */

class loop_item extends ExtTag
{
	function load()
	{
	}
	
	function validate()
	{
		global $vrk_loop_stack;
		if ($vrk_loop_stack == NULL)
		{
			return $this->throw_missing_parent_ex("vrk:loop_item", "vrk:loop");
		}
	}

	function build()
	{
		global $vrk_loop_stack;
		if ($vrk_loop_stack->cur_loop->can_parse_loop_item())
		{
			if ($this->type != "close")
			{
				$vrk_loop_stack->current_loop->parse = true;
				$this->handle_loop();
				return $this->value;
			}
		}
	}
}
?>


CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
One thing to try is to use a PHPCompatibility test to see what it reports. https://github.com/PHPCompatibility/PHPCompatibility

the issues seem to cascade.

Author

Commented:

Hi Arnold,


I think at this point I am way over my head so I am going to bow out. I am going to try and hire a PHP developer to see if the issue can be fixed. I appreciate all of the effort you have offered.

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
you might want to modernize versus having the new person go over old process.
It might be simpler to develop a new based on your years of use and possible additional features to be added, versus straight out repair of what you have.
Presumably your organization has grown over time, and might have additional items in mind.