Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,381 members, 7,819,390 topics. Date: Monday, 06 May 2024 at 03:25 PM

Php/mysql Codes - Strictly For Copy And Pasters! - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Php/mysql Codes - Strictly For Copy And Pasters! (826 Views)

Why A Blogger Should Never Copy And Paste / Can A Blogger Do Without Copy And Paste? / Complete Tutorials On Designing A Wapka.m0bi Site.(codes/scripts Etc) (2) (3) (4)

(1) (Reply)

Php/mysql Codes - Strictly For Copy And Pasters! by Nobody: 8:59am On Jan 31, 2009
This is strictly a copy-and-paste code section. Questions may be welcome!?!
So here we are going to be looking at some php copy and paste codes - few explanations where necessary.

We are going to dealing with code snippets, functions and maybe classes when necessary.


First code snippet will be dual php/mysql connector - this is a code that allows you to setup both your internet and local server config once so that if you upload you will not need to start creating new users account, especially if your local server and web server config settings are different,

Posts shall be continued later - i will have to search my archives for that code - the simple version that is.
Re: Php/mysql Codes - Strictly For Copy And Pasters! by Nobody: 9:17am On Jan 31, 2009
dual.config.php

<?php
############### config start ##################

//Internet server config
$webserver="mysite.com";
$web_username="cpanel_user";
$web_password="cpanel_pass";

//Local server config
$localserver="localhost";
$local_username="toni";
$local_password="laser";

//general config
$dbase_name_1="site_dbase";
$dbase_name_2="site_dbase2";

############### config stop ##################

###local server_name => 127.0.0.1,localhost or computername
function sonline() {if ($_SERVER['SERVER_NAME']=="localhost"||$_SERVER['SERVER_NAME']=="127.0.0.1"||strtolower($_SERVER['SERVER_NAME'])==strtolower(getenv('COMPUTERNAME'))) {return false;} else {return true;}}

if(sonline()) {
$server="$webserver";
$admin_user="$web_username";
$admin_pass="$web_password";
$dbname=$web_username.'_'.$dbase_name_1;
$dbname2=$web_username.'_'.$dbase_name_2;

//internet ftp setup
$ftp_server="$webserver";
$ftp_user_name="$admin_user";
$ftp_user_pass="$admin_pass";

} else {
//iis ftp setup
$ftp_server="localhost";
$ftp_user_name="Anonymous";
$ftp_user_pass="";

$server="$localserver";
$admin_user="$local_username";
$admin_pass="$local_password";
$dbname="$dbase_name_1";
$dbname2="$dbase_name_2";
}

?>




dual.connect.php
<?php
include_once 'dual.config.php';
$link = mysql_connect('localhost', $admin_user, $admin_pass);
if (!$link) {die('Could not connect to mysql server. Check your account settings! ' . mysql_error());}
if(!isset($dbname)) {die("No dbname specified in your server config, "wink;}
mysql_select_db($dbname,$link) or die ("Could not select database '$dbname'."wink;
?>

(1) (Reply)

Why Google Don't Love Me / Your Opinion Is Needed Here / Web Directory Submission

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.