Jump to content

jpnsol

New Members
  • Posts

    2
  • Joined

  • Last visited

jpnsol's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. HI there, I have just found the problem... I had added in www in to the path to get the ini file. Once I removed the www, it all works fine. $config = parse_ini_file('/var/www/vhosts/www.*******/db.ini'); // Needed to remove th ewww Thanks, John
  2. HI there, I am having a strange issue. I have a php script that says it is connected but when I check the connection object (a few lines of code later), I get error message: // Include connect.php which has connect function require('connect.php'); // Get connection Object from connect function $conn = connect(); // Prints: Connection is Successful // Check connection if( $conn === false){ die("ERROR: Could not connect. " . mysqli_connect_error()); // Prints: Could not connect. Access denied for user ''@'localhost' (using password: NO) } My code for connect is as follows <?php function connect() { // Path to Config File $config = parse_ini_file('/var/www/vhosts/*******/db.ini'); $conn = mysqli_connect("localhost",$config['username'],$config['password'],$config['db']); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } else { echo "Connection is successful"; } return $conn; } ?> Its as if the $conn object is NOT being returned properly in the connect() function. This code has worked in other sites. Any ideas?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.