homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

[HOWTO] PHP + MySQL on a mixed environment

5+ Year Member

Msg#: 4108798 posted 8:10 am on Apr 2, 2010 (gmt 0)

If you're - like me
- working on a project on your local windows machine, - want to regulary put your newly updated code on your linux webhost
- don't bother to always change the database and security settings on your local mysql daemon on every reinstall

this small script might help you.

function lib_mysql_connectdb($db)
$db_host= "localhost";
$db= $db;

if (file_exists("c:\WINDOWS\win.ini")) // we're on WINDOWS
$db_user= "root";
$db_pass= "";
else// we're on LINUX
$db_pass= "mr.Pas.Sword";
$db_user= $db;

$mysqllink= @mysql_connect($db_host, $db_user, $db_pass) or die(mysql_error());
@mysql_select_db($db) or die(mysql_error());
return $mysqllink;



WebmasterWorld Senior Member 5+ Year Member

Msg#: 4108798 posted 7:43 pm on Apr 2, 2010 (gmt 0)

Just to add to your effort, you can put yout DB connection code in an include file seperately, and have that uploaded once to your server. Local copy contains your windows host values and server copy contains your server mysql values, and your script includes that file. That way you wont have to change things on every upload. Just another way to do the same thing

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved