HI! In my company, customers have their own connections on SQL Server. So, I do a select and bring their connection data, but I'm having trouble passing these variables as parameters within the koolreport connectionstring.
This is my report.php:
<?php
include('Back_verifica_login.php');
include('Back_FuncaoConsulta.php');
$vardatabase=$_SESSION['BancoDeDados'];
$varUsername=$_SESSION['UID'];
$varPassword=$_SESSION['PWD'];
$varservername=$_SESSION['ServerName'];
require_once "./vendor/autoload.php";
use \koolreport\KoolReport;
use \koolreport\processes\Filter;
use \koolreport\processes\TimeBucket;
use \koolreport\processes\Group;
use \koolreport\processes\Limit;
class Report extends KoolReport
{
protected function settings(){
return array(
"dataSources"=>array(
"conexao"=>array(
"connectionString"=>"sqlsrv:server=$varservername;Database=$vardatabase",
"username"=>"$varUsername" ,
"password"=>"$varPassword"
)
)
);
}
Below is my setting. In report.php, I store the result of specific fields for my query within sessions (on another screen) and load them here by passing in variables, and inserting these variables in place of the connection fields.
I get the following error on my screen
Warning: Undefined variable $varservername in C:\xampp\htdocs\public\report.php on line 30
Warning: Undefined variable $vardatabase in C:\xampp\htdocs\public\report.php on line 30
Warning: Undefined variable $varUsername in C:\xampp\htdocs\public\report.php on line 31
Warning: Undefined variable $varPassword in C:\xampp\htdocs\public\report.php on line 32
Fatal error: Uncaught PDOException: SQLSTATE[42S02]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Nome de objeto 'vendas' inválido. in C:\xampp\htdocs\public\vendor\koolreport\core\src\datasources\PdoDataSource.php:428 Stack trace: #0 C:\xampp\htdocs\public\vendor\koolreport\core\src\datasources\PdoDataSource.php(428): PDOStatement->execute() #1 C:\xampp\htdocs\public\vendor\koolreport\core\src\KoolReport.php(315): koolreport\datasources\PdoDataSource->start() #2 C:\xampp\htdocs\public\indexReport.php(5): koolreport\KoolReport->run() #3 {main} thrown in C:\xampp\htdocs\public\vendor\koolreport\core\src\datasources\PdoDataSource.php on line 428
Remembering that I defined the variables up there. Am I putting things in the right order? Please help me, thank you.