MySQL Forums
Forum List  »  PHP

MYSql Website won't connect
Posted by: Dan Ocenas
Date: September 08, 2020 01:39PM

I am trying to help a fiend with migrating a website from one host to a new host. I have uploaded and moved everything in place but the DB won't connect. The original code is

<?php
function db_connect()
{
//connnect to database
$dbcnx = mysqli_connect("127.0.0.1", "", '', '')
or die ("Could not connect to db. Error: ". mysqli_errno($GLOBALS['db']) . mysqli_error($GLOBALS['db']));
$GLOBALS['db'] = $dbcnx;
return $dbcnx;
}

I can establish a connection to the DB with the following but the queries won't work.

<?php
function db_connect()
{
//connnect to database
$dbcnx= new mysqli("l", "", '', '')
or die ("Could not connect to db. Error: ". mysqli_errno($GLOBALS['db']) . mysqli_error($GLOBALS['db']));
$GLOBALS['db'] = $dbcnx;
return $dbcnx;
}


Thoughts please help it has been a long time since I have done MySQL so I am a bit rusty.

Options: ReplyQuote


Subject
Written By
Posted
MYSql Website won't connect
September 08, 2020 01:39PM
September 08, 2020 03:56PM
September 08, 2020 08:27PM
September 09, 2020 09:33AM
October 25, 2020 03:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.