Jump to content

Recommended Posts

Posted

Hi all,

I am  a php (lamer)  and about to play a bit with coding, a simple php-file as for now

coming that far

<?php

$servername = "localhost";
$username = "xxx_user";
$password = "99999999";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

echo "Connected successfully";
?>

The above connects fine.

Needing to read out the corresponding values  from /config/blesta.php

Anyone can push me the right way?

Tiny

 


 

 

 

 

Posted
10 hours ago, Tiny said:

Hi all,

I am  a php (lamer)  and about to play a bit with coding, a simple php-file as for now

coming that far

<?php

$servername = "localhost";
$username = "xxx_user";
$password = "99999999";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);

echo "Connected successfully";
?>

The above connects fine.

Needing to read out the corresponding values  from /config/blesta.php

Anyone can push me the right way?

Tiny

 


 

 

 

 

Blesta use PDO , and use Configure class to set/read vars. so first you need to use the Configure class to read the dbinfo

so you can include the blesta config and do something like that :

$db = Configure::get('Blesta.database_info');

try {
    $dbh = new PDO('mysql:host=' . $db['host'] .';dbname=' . $db['database'], $db['user'], $db['pass']);
} catch (PDOException $e) {
    print "Erreur !: " . $e->getMessage() . "<br/>";
    die();
}

 

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...