Jump to content
php.lv forumi

DB selektosana


Zoom

Recommended Posts

Man ir sasapejusi problema :blink:

Es izveidoju SKRIPTU kurs izveido DB un DB ieliek tabulas. Nosauksim par install skriptu. Tad es velos uztaist DB skriptu, kur ir sada infa: DB nosaukums, servera adrese, lietotaja vards, parole. Sos 4 es caur install skriptu ierakstiju DB. Bet tagad es gribu selektot DB un parejo infu. Radas viena "maza" problema. No kuras DB es selektosu so infu :huh:. Iznak, ka es selektoju no nekuriens, lai dabutu lietotaja izveidotas db nosaukumu. :lol:. Ko jus iesakat. Cerams manu sviestu sapratat. Aizmirsu piebilst, ka sada sitema ir e107 php dzinejam. Kur saraksta visus datus un viss. Dzinejs nem info tikai no lietotaja izveidotas DB. Es gribeju uztaist lidzigu sitemu.

Edited by Zoom
Link to comment
Share on other sites

nu takš pie DB izveides tiek saglabāta arī konfigurācija...

 

kaut vai

 

fwrite( fopen('db_config.php','w'), serialize($_POST) );

 

un turpmāk savos skriptos inkludo tā faila masīvu

 

$DBCFG = unserialize( file_get_contents('db_config.php') );

Link to comment
Share on other sites

ok thx. Man uzgenerejas strings. Man vnk inkludot ara ?

<?php

include $DBCFG = unserialize( file_get_contents('db_config.php') );


?>

met ara sadu erroru:

Warning: main(Array): failed to open stream: No such file or directory in C:\Program Files\Apache Group\Apache2\htdocs\priv\serveris\macibu\mans gbook\test.php on line 2

 

Warning: main(): Failed opening 'Array' for inclusion (include_path='.;c:\php4\pear') in C:\Program Files\Apache Group\Apache2\htdocs\priv\serveris\macibu\mans gbook\test.php on line 2

uzgenereja sadu strindu

a:5:{s:6:"dbname";s:9:"tetstejam";s:6:"server";s:9:"localhost";s:8:"usr_name";s:6:"einars";s:4:"pasw";s:0:"";s:4:"done";s:9:"Izveidot!";}

 

sita?? :

<?php
$DBCFG = unserialize( file_get_contents('db_config.php') );
mysql_select_db($dbname) or die(mysql_error());
mysql_connect ($server, $usr_name, $pasw) or die (mysql_error());

?>

Edited by Zoom
Link to comment
Share on other sites

×
×
  • Create New...