PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old October 29th, 2002, 02:07 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
configuration

you know on like phpbb where you fill out a form with the database information, etc and it sets that as all the veriables, well how does it do that? like how would the admin of the script put in his username and passwrod for the database in the config file and have it stay that way in the script wihtout him re entering it?

Reply With Quote
  #2  
Old October 29th, 2002, 02:15 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration


Quote:
you know on like phpbb where you fill out a form with the database information, etc and it sets that as all the veriables, well how does it do that?


It just saves them to a configuration file. You can download the phpBB source and check it out...

Reply With Quote
  #3  
Old October 29th, 2002, 02:30 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

i did but its really compressed, almost unreadable.. does it write it to a text file, or store it in a database or what?

Reply With Quote
  #4  
Old October 29th, 2002, 02:37 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

The database settings would have to be stored in a text file, otherwise it wouldn't know how to connect to the database to retrieve the info

Reply With Quote
  #5  
Old October 29th, 2002, 11:20 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

lol.. oops, ok so do i just write it to a text file?

Reply With Quote
  #6  
Old October 30th, 2002, 12:27 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

yep..

Reply With Quote
  #7  
Old October 30th, 2002, 01:47 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

index.php (form):
**********************************
<form method="post" action="read.php">
<table><tr>
<td>Mysql Host:</td><td><input type="text" name="dbhost" value="localhost"></input><br>your mysql host.</td></tr><tr>
<td>Mysql UserName:</td><td><input type="text" name="dbuname" value="username"></input><br>your username to log into mysql.</td></tr><tr>
<td>Mysql Password:</td><td><input type="text" name="dbpass" value="password"></input><br>your password to log into mysql.</td></tr><tr>
<td>Mysql Database:</td><td><input type="text" name="database" value="ccshop"></input><br>The CCShop Mysql Database Name.</td></tr><tr>
</tr></table>
<input type="submit" name="submit" value="Next"></input>
</form>
***************************************
***************************************


read.php:
***************************************

<?
$infofile = "../config.php";
if (file_exists($infofile))
{
print "The config file already exists";
}
else
{
$info = fopen("$infofile", "a+");
fputs($info, "<?rn");
fputs($info, "$");
fputs($info, "dbhost");
fputs($info, "='$dbhost';rn");
fputs($info, "$");
fputs($info, "dbuname");
fputs($info, "='$dbuname';rn");
fputs($info, "$");
fputs($info, "dbpass");
fputs($info, "='$dbpass';rn");
fputs($info, "$");
fputs($info, "database");
fputs($info, "='$database';rn");
fputs($info, "="$");
fputs($info, "$");
fputs($info, "db = mysql_pconnect($");
fputs($info, "dbhost, $");
fputs($info, "dbuname, $");
fputs($info, "dbpass);rn");
fputs($info, "mysql_select_db($");
fputs($info, "database) or die ("Unable to select database");rn");
fputs($info, "?>rn");
fclose($info);
}
echo "<center>Your Config.php file has been created!";
?>
****************************************
****************************************

I put the $ seperated on each line because when the $variable is placed together you get your text instead of variable.
*****************************************
like:
fputs($info, "$");
fputs($info, "db = mysql_pconnect($");
fputs($info, "dbhost, $");
fputs($info, "dbuname, $");
fputs($info, "dbpass);rn");

makes:
$db = mysql_pconnect($dbhost, $dbuname, $dbpass);
*****************************************
if you put it in this script:

fputs($info, "$");
fputs($info, "db = mysql_pconnect($dbhost, $dbuname, $dbpass);rn");

in place for database connect... it will make this:

$db = mysql_pconnect(localhost, username, password);

so you want to make sure you dont do that.
unless you want the text placed there instead.

like:
fputs($info, "$");
fputs($info, "dbhost");
fputs($info, "='$dbhost';rn");

makes:
$dbhost='localhost';

if localhost is what is typed in the textbox.

this will create a config.php in the folder above the folder this script is in.

like admin/install/
and puts the config.php in admin/

this is what i use, its to put info into a flat file database...

your config.php will look like this:
******************************************

<?
$login='admin';
$pass='pass';
$dbhost='localhost';
$dbuname='admin';
$dbpass='k4tm4nn';
$database='ccshop';
$db=mysql_pconnect($dbhost, $dbuname, $dbpass);
mysql_select_db($database) or die ("Unable to select database");
?>

**************************
sorry this is so long, but it works.. its what i use for ccshop at www.spidermonster.com

Reply With Quote
  #8  
Old October 30th, 2002, 01:49 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
RE: configuration

sorry, and the above is a config.php not a txt file, even though you can make it a text file. ths lets me save it as config.php

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > configuration


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway