Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] Problem z file_get_contents()
webber
post
Post #1





Grupa: Zarejestrowani
Postów: 107
Pomógł: 19
Dołączył: 30.10.2007

Ostrzeżenie: (0%)
-----


Witam,

Zapisuje dane konfiguracyjne tak:
  1. $nazwa_pliku = '../config/configuration.php';
  2. chmod(''.$nazwa_pliku.'', 0700); // don`t touch my config dude! biggrin.gif
  3. $array = array(''.$_POST['db_server'].'', ''.$_POST['db_name'].'', ''.$_POST['db_user'].'', ''.$_POST['db_password'].'');
  4. $contents = implode('|', $array);
  5. file_put_contents($nazwa_pliku, '<?php die("What are you looking for?"); ?>'.$contents.'');


Odczytuje tak:

  1. $configurations = file_get_contents ('config/configuration.php');
  2. $config = explode('|', $configurations);


Przypisuje do zmiennych:

  1. $db_server = $config[0];
  2. $db_name = $config[1];
  3. $db_user = $config[2];
  4. $db_password = $config[3];


Wyświetlając

  1. echo $db_server;
mam localhost, ale dając już to tak:

  1. $db_handle = mysql_connect($db_server, $db_user, $db_password);
  2. $db_found = mysql_select_db($db_name, $db_handle);


Do zmiennej $db_server dopisuje mi: <?php die("What are you looking for?"); ?>,

Teraz pytanko, jak zrobić by poprawnie czytało z pliku, ewentualnie czy inaczej zapisywać konfiguracje w pliku? Chociaż przyznam, że takie rozwiązanie mnie odpowiada smile.gif

Ten post edytował webber 21.08.2009, 23:46:50


--------------------
"CSS is like a girlfriend. No matter how hard you try, she will always interpret it a different way."
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 21:46