Skip to content

Instantly share code, notes, and snippets.

@simeondahl
Last active December 10, 2015 18:39
Show Gist options
  • Select an option

  • Save simeondahl/4476492 to your computer and use it in GitHub Desktop.

Select an option

Save simeondahl/4476492 to your computer and use it in GitHub Desktop.
A connect to mysql system.
0.0.1 -> 0.0.2
general:
- New function to show or hide the disabled message
- Added a comment in "mysql.php"
0.0.1
general:
- New function to disable/enable website frontpage
- Fixed a frew bugs
- Fixed comments on "config.php" and "mysql.php"
<?php
/*
Here you can set the settings on your website
*/
// MySQL settings
$mysql_enabled = true; // set to false if you do not use mysql
$mysql_host = "localhost"; // the host you mysql are on
$mysql_user = "root"; // the mysql login name
$mysql_pass = "1234"; // your mysql password
// Site settings
$site_enabled = true; //if you want you website to be showed
$site_show_disabled = true, // if you want to show a message is you have disabled your site
?>
<?php
require ("config.php");
// it do so iw will only show your html code, if you have set $site_enabled to "true" in config.php
if ($site_enabled == true) { ?>
<!-- code your html here -->
<?php } else if ($site_show_disabled == true && $site_enabled == false) { ?>
<!-- You can change this as you like to, but dont delete <?php } ?> -->
The website is not active right now. Please come back later.
<?php } ?>
<?php
// this script will allow you to connect to your mySQL database, and give a error it it do not work
require ("config.php");
// this just set you use mysql, else it will not be enabled (default "true" in config.php)
if ($mysql_enabled == true) {
!con = mysql_connect( "$mysql_host", "$mysql_user", "$mysql_pass" );
if (!con) {
die("Can't connect: " . mysql_error()); // this show the erorr is something is wrong
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment