LordOfSpoon LordOfSpoon - 1 month ago 7
MySQL Question

Database login incorrect

I'm having some trouble with some software that I'm tweaking. During my install script I can type my database username, database name, localhost, etc and once I click next it is suppose to connect to the database and start the install. However when I click next I have shown this error:


Database Login Incorrect: config.php


Here is my config.php file:

<?php

// Mysql Settings
$mysqli_host = "";
$mysqli_login = "";
$mysqli_pass = "";
$mysqli_database = "";
$db_prefix = "";

$_dbConn = mysqli_connect($mysqli_host, $mysqli_login, $mysqli_pass)
or die ('Database Login Incorrect: config.php');

mysqli_select_db($mysqli_database, $_dbConn)
or die ('Unable to select the database: config.php');

?>


Although the database name and username are correct and have proper permissions. I can show the install file but it is over 2k lines and didn't want to post all of that :p

Thanks for your time!

Edit:

After using Geo V L's fix, I now have the error of "have you run install.php yet?". This is located in my structure.php file:

// Include functions...

include "scripts/php/functions.php";

// get board theme

$query2 = "select THEME from {$db_prefix}settings";
$result2 = mysqli_query($query2) or die("Have you run install.php yet?");
$theme = mysqli_result($result2, 0);

Answer

In this code snippent $_dbConn will be the first parameter for mysqli_select_db

    <?php

// Mysql Settings
  $mysqli_host      = "";
  $mysqli_login     = "";
  $mysqli_pass      = "";
  $mysqli_database  = "";
  $db_prefix            = "";

  $_dbConn = mysqli_connect($mysqli_host, $mysqli_login, $mysqli_pass)
  or die ('Database Login Incorrect: config.php');

  mysqli_select_db( $_dbConn,$mysqli_database)
  or die ('Unable to select the database: config.php');

?>

Or you can directly add databasename on mysqli connect string like the following

    <?php

// Create connection
$conn = mysqli_connect($mysqli_host, $mysqli_login, $mysqli_pass, $mysqli_database);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
?>
Comments