只读mysql数据库

I'm trying to get work this small project. I have master-admin over classic admin.

my database connection is establish on cookie $key. If i have cookie google, it looks into my master-admin database and search there for DB_PASSWORD, DB_HOST etc. And then it build config.php. This cookie is set to expire after few days.

This is my config.php :

<?php


$key = $_COOKIE["nazev_webu"];

$sql = mysql_query("SELECT * FROM weby WHERE nazev='$key'");

while($row = mysql_fetch_array( $sql )) {
    // Print out the contents of each row into a table
$name = $row['DB_NAME'];
$pass =  $row['DB_PASSWORD'];
$user =  $row['DB_USER'];
$host = $row['DB_HOST'];



  }
  //připojení dataze
$connect = mysql_connect($host, $user, $pass) 
  or die("Nelze se připojit k databázi");

  //výběr databáze
$select = mysql_select_db($name ,$connect) 
  or die("Nemohu vybrat databázi");

?>

it works perfectly but only in "read only mode". I can select from database but if I'm trying to insert or update something i get this error.

Warning: mysql_query() [function.mysql-query]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /data20/website/html/config.php on line 7

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /data20/website/html/config.php on line 7

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /data20/website/html/config.php on line 9

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /data20/website/html/config.php on line 20

I have to say that insert and update action are build on ajax call, so i post via ajax id of article f.e.. to the update script.

I think problem can be that mysql are on another server, not on the same server as is my website.

The solution is too easy. I forgot to include static database connection into this file. So it can't look into database and get from here connection details for new config.php.