Error Connecting to Database PHP MySQL

I am having problems connecting with a database using a php form. I have created a separate file for php database parameters.

<?
$db_username = "username";
$db_password = "password";
$db_name = "db";
$db_host = "host";

?>

Include statement

include "db_data.php";

This is my connection String

$dblink =   $Database->connect($db_username, $db_password, $db_name, $db_host);

This is my database class

<?php

class Database{

var $dblink;
var $query_error;
var $username;
var $password;
var $host;
var $database;



function connect ($username, $password, $dbname, $host) {
$this->dblink = mysql_connect($host, $username, $password);
mysql_select_db($dbname);


if($this->dblink == ""){
    echo "Error connecting to database $database<Br>";
    return -1;
  }else{
  return $this->dblink;
  }
 }


 function disconnect(){
   mysql_close($this->dblink);
   }



   }



  ?>

I haven’t changed any of my connection parameters. Will starting again mysql server solve the problem ??

Thanks Jose

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s