I am trying to connect to a database named BetaPoints. All of the credentials are located in a php file name EstablishAccess.php in the format of
<?php define (DB_USER, "BetaPoints"); define (DB_PASSWORD, "password!"); define (DB_DATABASE, "BetaPoints"); define (DB_HOST, "hostname"); ?> I am trying to connect to the database with this
$connctn=mysql_connect($DB_HOST,$DB_USER,$DB_PASSWORD) or die("cannot connect to database"); mysql_selectdb('BetaPoints') or die('cannot select database'); I am getting this error:
Notice: Undefined variable: DB_HOST in /home/content/06/8274306/html/beta/mysuperscript.php on line 6
Notice: Undefined variable: DB_USER in /home/content/06/8274306/html/beta/mysuperscript.php on line 6
Notice: Undefined variable: DB_PASSWORD in /home/content/06/8274306/html/beta/mysuperscript.php on line 6
Warning: mysqli_connect() [function.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/06/8274306/html/beta/mysuperscript.php on line 6 cannot connect to database
I have look for mistakes in my variables and I have logged in multiple times with the credentials that I have defined to those variables and I am still unable to find the mistake.
It says that I can not connect to local MySQL database when to my knowledge it is not a local database.
If any one has any suggestion post them below. I am trying to get help finding more information about what is going wrong and any solutions that I can do to make it work.
mysql_selectdb('BetaPoints', $connctn)- Do use up-to-date APIs such asmysqli_or PDO. Add error reporting to the top of your file(s) right after your opening PHP tag for example<?php error_reporting(E_ALL); ini_set('display_errors', 1);then the rest of your code, to see if it yields anything. If you get a deprecation notice, then you'll know what to use instead.mysqli_connect()coming from? You cannot mix APIs like that.