Jump to content

I cant connect with mysql ???


sella2009

Recommended Posts

I try to connect to mysql but it doesnt work  :confused: and I get this error "Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'DB_HOST' (11004) in C:\xampp\htdocs\project\project\index.php on line 35

Could not connect to DB_HOST"

Here is the code for my index. php

<?php

require("smarty/Smarty.class.php");
require("intouch.lib.php");
require("intouch.cfg.php");

/* Set version info */
define("INTOUCH_VERSION","v0.5.1 Alpha");

/* Open the DB connection */
mysql_connect(DB_HOST,DB_USER,DB_PASS)
  or die("Could not connect to ".DB_HOST);
mysql_select_db(DB_NAME) 
  or die("Could not select database ".DB_NAME);

/* Starting the session */
session_start();

/* Register session and init if it does not exist */
if(!session_is_registered("session")) {
  session_register("session");

  /* Initalize the session */
  login_reset();
}

if(isset($session['action'])&&!isset($action))
  $action = $session['action'];
elseif(isset($action))
  $session['action'] = $action;

$index = new Smarty;
$error = NULL;

/* Logout => Reset the session */
if($action=="logout") {
  login_reset();
  $error = OK_LOGGED_OUT;
  $action = "login_show";
}

/* Let's do some authentification here */
if($action=="login_verify") {
  if($session["userid"] = login_verify($user,$password)) {
    $action = "addr_list_show";
    $session["logged_in"] = true;
  }
  else {
    $action = "login_show";
    $error = ERR_INV_AUTH;
  }
}

/* Deciding what to do... */
switch($action) {
  case "gb_show":
    $session["logged_in"] ? gb_show($page) : login_show(ERR_LOGIN_REQ);
  break;
  case "gb_sign_show":
    $session["logged_in"] ? gb_sign_show() : login_show(ERR_LOGIN_REQ);
  break;
  case "gb_sign_insert":
    if($session["logged_in"]) {
      gb_sign_insert($text);
      gb_show(0);
    } 
    else login_show(ERR_LOGIN_REQ);
  break;
  case "gb_del":
    $session["logged_in"] ? gb_del($gbid,$conf) : login_show(ERR_LOGIN_REQ);
  break;

  case "addr_list_show":
    $session["logged_in"] ? addr_list_show($nalpha,$classid,$order) : login_show(ERR_LOGIN_REQ);
  break;
  case "addr_user_show":
    $session["logged_in"] ? addr_user_show($userid) : login_show(ERR_LOGIN_REQ);
  break;
  case "addr_user_edit":
    $session["logged_in"] ? addr_user_edit($userid) : login_show(ERR_LOGIN_REQ);
  break;
  case "addr_user_update":
    $session["logged_in"] ? addr_user_update($user) : login_show(ERR_LOGIN_REQ);
  break;
  case "addr_user_del":
    $session["logged_in"] ? addr_user_del($userid,$conf) : login_show(ERR_LOGIN_REQ);
  break;
  case "addr_toggle_admin":
    $session["logged_in"] ? addr_toggle_admin($userid,$admin,$nalpha,$classid,$order) : login_show(ERR_LOGIN_REQ);
  break;

  case "new_account_show":
    new_account_show();  
  break;
  case "new_account_insert":
    if(new_account_insert($account))
      login_show(OK_ACCOUNT_CREATED);
  break;
  case "login_show":
  default:
    login_show($error);
  break;
}

$index->assign("intouch_version",INTOUCH_VERSION);
$index->display("index.tpl");

/* Close DB connection */
mysql_close();
?>

 

and here is the code for my  intouch.cfg.php

 

<?


/* database settings */
define("DB_USER","project");
define("DB_PASS","123456");
define("DB_NAME","project");
define("DB_HOST","localhost");

/* guestbook settings */
define("GB_ENTRIES_PER_PAGE",10);
define("GB_ALLOW_HTML",true);

/* error messages */
define("ERR_INV_AUTH","Invalid user or password!");
define("ERR_LOGIN_REQ","You need to login before you can do this!");
define("ERR_MISS_FIELDS","Some required fields are not filled. Check your submission!");
define("ERR_PASSES_DONT_MATCH","The two passwords don't match!");
define("ERR_USR_NOT_UNIQUE","Your username does already exist! Choose another one...");
define("ERR_UNABLE_CREATE_ACCOUNT","Wired, I was unable to create a new account, contact your sysadmin blah, blah...");

/* success messages */
define("OK_ACCOUNT_CREATED","Your account has been successfully created! Login now...");
define("OK_LOGGED_OUT","Successfully logged out!");
?>

 

I have entered the right password and everything and it seems like its not working and I still get that error, can anyone here please help????????

Link to comment
https://forums.phpfreaks.com/topic/186857-i-cant-connect-with-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.