Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error Connecting to database #8

Open
techkimchhay opened this issue May 6, 2018 · 4 comments
Open

Error Connecting to database #8

techkimchhay opened this issue May 6, 2018 · 4 comments

Comments

@techkimchhay
Copy link

I am trying to connect to database but get an error like this

`C:\wamp64\www\smb-report\vendor\geekcom\phpjasper-laravel\src\PHPJasper.php
/**
* @param bool $user
* @return mixed
* @throws Exception\InvalidCommandExecutable
* @throws Exception\InvalidResourceDirectory
* @throws Exception\ErrorCommandExecutable
*/
public function execute($user = false)
{
$this->validateExecute();
$this->addUserToCommand($user);

    $output = [];
    $returnVar = 0;

    chdir($this->pathExecutable);
    exec($this->command, $output, $returnVar);
    if ($returnVar !== 0) {
        //throw new \PHPJasper\Exception\ErrorCommandExecutable();
        throw new \Exception("{$output[0]}", 1);
    }

    return $output;
}

/**
 * @return string
 */
public function output()
{
    return $this->command;
}

/**
 * @param $user
 */
protected function addUserToCommand($user)
{
    if ($user && !$this->windows) {
        $this->command = 'su -u ' . $user . " -c \"" . $this->command . "\"";

Arguments
"usage: jasperstarter process [-h] -f [ ...] [-o ] [-w]"`

and here is my config

` public function generate()
{
//$input = DIR . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
$input = base_path('/vendor/geekcom/phpjasper-laravel/examples/Database.jasper');
$output = base_path('/vendor/geekcom/phpjasper-laravel/examples');

    $options = [
        'format' => ['pdf'],
        'locale' => 'en',
        'db_connection' => [
            'driver' => 'mysql',
            'username' => 'root',
            'password' => '',
            'host' => '127.0.0.1',
            'database' => 'smb',
            'port' => '3306'
        ]
    ];

    $jasper = new PHPJasper;

    $jasper->process(
        $input,
        $output,
        $options
    )->execute();
    return view('welcome');
}`

could you please help to tell what's went wrong?

@jorgeescobar
Copy link

Good afternoon, I have the same or similar mistake
usage: jasperstarter process [-h] -f <fmt> [<fmt> ...] [-o <output>] [-w]
Help, please

@jorgeescobar
Copy link

with this code the error does not come out anymore, but the fields in the report come out as NULL
$jasper->process( $input, $output, array('pdf', 'rtf'), array('php_version' => phpversion()), array( 'driver' => 'mysql', 'username' => 'root' 'password' => '', 'host' => 'localhost', 'database' => 'ksoftdb', 'port' => '3306',) )->execute();
help please...

@geekcom
Copy link
Member

geekcom commented Jun 27, 2018

Please check the parameters of your DB

@sfdsfdsfdesfdsghefasefs
Copy link

sfdsfdsfdesfdsghefasefs commented May 23, 2019

You missing , (comma) after username root. in connection array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants