Connecting to a MySQL database via php in bluehost -
Connecting to a MySQL database via php in bluehost -
hi im having mysql database on bluehost , i'm trying connect using php. php files used stored in public_html under domain. given below 2 codes
db_config.php
<?php /* * database connection variables */ define('db_user', "siveradi_root"); // db user define('db_password', "tesh123"); // db password (mention db password here) define('db_database', "siveradi_test"); // database name define('db_host', "localhost:3306"); // db server define('db_port',"3306"); ?>
db_connect.php
<?php /** * class file connect database */ class db_connect { // constructor function __construct() { // connecting database $this->connect(); } // destructor function __destruct() { // closing db connection $this->close(); } /** * function connect database */ function connect() { // import database connection variables require_once __dir__ . 'http://mangominds.info/test_mera/db_config.php'; // connecting mysql database $con = mysql_connect(db_host, db_user, db_password) or die(mysql_error()); // selecing database $db = mysql_select_db(db_database) or die(mysql_error()) or die(mysql_error()); // returing connection cursor homecoming $con; } /** * function close db connection */ function close() { // closing db connection mysql_close(); } } ?>
however when seek connect database through
<?php $db = new db_connect(); // creating class object(will open database connection) ?>
an error shown saying "server error website encountered error while retrieving http://mangominds.info/test_mera/tt.php. may downwards maintenance or configured incorrectly."
please advice on needs done
maybe if remove port define('db_host', "localhost:3306"); // db server
and create it:
define('db_host', "localhost"); // db server
also seek not comment lastly line port number , leave db_host definition without port
mysql bluehost
Comments
Post a Comment