<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Building Browsergames - Latest Comments in Building Browsergames: Using Configuration Files (PHP)</title><link>http://bbgames.disqus.com/</link><description></description><atom:link href="https://bbgames.disqus.com/building_browsergames_using_configuration_files_php/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Sat, 22 Mar 2014 22:36:27 -0000</lastBuildDate><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-1297070387</link><description>&lt;p&gt;Hullo everybody,&lt;br&gt;sorry for my English, I'm foreign. Since a &lt;br&gt;browsergame is a really complex project I'd recommend to use a flexible &lt;br&gt;database class... on other pages related to a users/monsters stats, if &lt;br&gt;I'm right, someone mentioned the DRY principles... If u use a class &lt;br&gt;there can't be any repetition anymore... ;)&lt;br&gt;I always use the same &lt;br&gt;class in my projects cause it is very handy and can be recycled for &lt;br&gt;everything... here is a shorter version and only a tiny part of it for &lt;br&gt;you as an example... I hope I made no mistake cause I only wrote it only&lt;br&gt; for this comment and couldn't test it... But you might see which &lt;br&gt;direction it gives you...&lt;/p&gt;&lt;p&gt;class databaseConfiguration {&lt;/p&gt;&lt;p&gt;    protected $dbhost;&lt;br&gt;    protected $dbuser;&lt;br&gt;    protected $dbpass;&lt;br&gt;    protected $dbname;&lt;br&gt;    protected $connection;&lt;br&gt;    public $errormessage;&lt;/p&gt;&lt;p&gt; public function __construct($databasehost = "localhost", $databaseuser =&lt;br&gt; "root", $databasepass = "", $databasename = "project") {&lt;br&gt;        $this-&amp;gt;dbhost = $databasehost;&lt;br&gt;        $this-&amp;gt;dbuser = $databaseuser;&lt;br&gt;        $this-&amp;gt;dbpass = $databasepass;&lt;br&gt;        $this-&amp;gt;dbname = $databasename;&lt;br&gt;    }&lt;/p&gt;&lt;p&gt;    public function db_connection() {&lt;br&gt;        $this-&amp;gt;connection     =     @mysqli_connect($this-&amp;gt;dbhost,$this-&amp;gt;dbuser,$this-&amp;gt;dbpass);&lt;br&gt;        $this-&amp;gt;selection    =     @mysqli_select_db($this-&amp;gt;dbname);&lt;/p&gt;&lt;p&gt;        if ($this-&amp;gt;connection == false) {&lt;br&gt;            $this-&amp;gt;errormessage = "blablabla";&lt;br&gt;        }&lt;/p&gt;&lt;p&gt;        if ($this-&amp;gt;selection == false) {&lt;br&gt;            $this-&amp;gt;errormessage = "blablabla";&lt;br&gt;        }&lt;br&gt;    }&lt;/p&gt;&lt;p&gt;    // ... everything else related to the databases and which might be used more than twice could be added as another method,...&lt;br&gt;}&lt;/p&gt;&lt;p&gt;you just need to include it from an external file as Luke figured out and call to the class and the method with...&lt;/p&gt;&lt;p&gt;$db_conn = new databaseConfiguration("","","","");&lt;br&gt;$db_conn-&amp;gt;db_connection();&lt;/p&gt;&lt;p&gt;I used optional parameters so you can also use it for every database you like... &lt;br&gt;You can make flexible methods for select, update, insert, too... ;)&lt;/p&gt;&lt;p&gt;Hope this hint was useful....&lt;br&gt;Pandora&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Pandora</dc:creator><pubDate>Sat, 22 Mar 2014 22:36:27 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-27536621</link><description>&lt;p&gt;You use config.php to store configuration values that both scripts&lt;br&gt;will need to use - for now we're just storing database settings, but&lt;br&gt;as your game grows you may find yourself needing to store more and&lt;br&gt;more values related to configuring your game - config.php is how we&lt;br&gt;solve that problem.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke</dc:creator><pubDate>Wed, 30 Dec 2009 03:20:18 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-27533786</link><description>&lt;p&gt;I have already created the "login.php" and "register.php" : both woring 100%&lt;br&gt;but I still can´t understand the "config.php" file.&lt;/p&gt;&lt;p&gt;I dont really get what shall I type on the "config.php" file.&lt;/p&gt;&lt;p&gt;Thanks, and great tutorial!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">ricardokb</dc:creator><pubDate>Wed, 30 Dec 2009 02:33:55 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-7681758</link><description>&lt;p&gt;Hi Sean,&lt;br&gt;What do you mean by 'fails'? As long as you've written an .htaccess rule to&lt;br&gt;disallow users to view config.php, it should be virtually impossible for a&lt;br&gt;user who doesn't have access to the web server to read your configuration&lt;br&gt;file.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke</dc:creator><pubDate>Tue, 31 Mar 2009 14:08:30 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-7678976</link><description>&lt;p&gt;What happens when the engine fails and someone sees all the information on this page?&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Sean</dc:creator><pubDate>Tue, 31 Mar 2009 12:22:20 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-7066707</link><description>&lt;p&gt;You have really written a wonderful tutorial, which contains just what I need! Thanks for linking every php code to the right page, this time it helped me easily figure the difference between require and require once, and require and include! Which I both did not know before (the differences)&lt;br&gt;Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">lollige</dc:creator><pubDate>Tue, 10 Mar 2009 07:44:39 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-3089086</link><description>&lt;p&gt;Hi Adam,&lt;/p&gt;&lt;p&gt;Thanks for pointing out parse_ini_file - seeing as we've already done all of our configuration work for now, we probably won't be using it in this project - but it's on my list of things to use for the next one.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke</dc:creator><pubDate>Thu, 10 Jul 2008 10:24:10 -0000</pubDate></item><item><title>Re: Building Browsergames: Using Configuration Files (PHP)</title><link>http://buildingbrowsergames.com/2008/04/22/building-browsergames-using-configuration-files-php/#comment-3089085</link><description>&lt;p&gt;I find PHP's parse_ini_file an efficient and very handy method to use for storing configuration as you can split settings up into multiple sections and such as you add more settings.&lt;/p&gt;&lt;p&gt;~ Adam&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Adam</dc:creator><pubDate>Thu, 10 Jul 2008 04:15:43 -0000</pubDate></item></channel></rss>