hi ive picked up a script and although ive put database details in its not picking them up heres the database file ommiting my database details of course


    ini_set("display_errors", 0); 
    $hostname = "localhost";
    $database = "matureco_test";
    $password = "xxxxx";
    $username = "xxxx";

and heres the database file

$conn = mysqli_connect($hostname, $username, $password,$database);
if (!$conn) {
    die('Could not connect !');
$sqlcf = 'select Variable, Value from '.$table_prefix.'site_settings where IsRead = 0';
$qrycf = mysqli_query($conn,$sqlcf);
    die('Can not load config data !');
    while($rowcf = mysqli_fetch_array($qrycf)){
            $$rowcf['Variable'] = explode(',', $rowcf['Value']);
            $$rowcf['Variable'] = intval($rowcf['Value']);
            $_SESSION['lang'] = isset($_SESSION['lang'])?$_SESSION['lang']:$rowcf['Value'];
        else eval("$\$rowcf['Variable'] = \"$rowcf[Value]\";");
else die('Can not find setting table !');

and heres the install file

if(!mysqli_connect ($GLOBALS["hostname"],$GLOBALS["username"],$GLOBALS["password"])){
    echo '<form><font color="#FF0000"><i>Can not connect database !<br>';
    echo 'Open config.php in \'includes\' folder and update the followings values: Hostname, username, password, database name.<br>';
    echo 'Save your settings and reload this page.<br><br></i></font>';
    echo '<input type="button" class="submit_btn float_l" value="RELOAD" onClick="window.location.reload()"/></form>';

what im getting in error log

[19-Nov-2016 13:34:57 America/Chicago] PHP Notice:  Undefined variable: conn in
[19-Nov-2016 13:34:57 America/Chicago] PHP Warning:  mysqli_select_db() expects parameter 1 to be mysqli, null given in

ive googled but not found a solution any help would be much appreciated ty x

Member Avatar

Confused. Why have you got two connection routines? WHat's the purpose of the install file?
Your errors usually mention line numbers - which lines are we talking about? One error mentions mysqli_select_db() - I can't see it.

The code, no offence, looks like a dog's dinner.

mysqli_set_charset has the params the wrong way around.

Not sure why you're creating unknowable variable names: $$rowcf['Variable'] - you'd be far better placing variable-value pairs in an array.
Do you really need to use eval()?

hi ive picked up a script and ...

If you don't understand it, don't use it. Anybody can use a script, but using a script properly / safely means that you understand the basics of the language, your members - who I'm sure want to stay anonymous(!), may have details laid bare.

May I ask what software you are trying to install? Perhaps we would get further by checking out the github project, etc for ourselves. At the very least, perhaps we might be able to point you to a better written alternative.