rajeshkumarvm Posted October 11, 2007 Share Posted October 11, 2007 <?php $db_host = "localhost"; $db_user = "root"; $db_pwd = "rajesh"; $db_dbname = "test"; mysql_connect($db_host, $db_user, $db_pwd) or die("Could not connect: " . mysql_error()); $seldb = mysql_select_db($db_dbname) or die("Could not connect: " . mysql_error()) ; ?> This is my actual page.In this page i dont want to view the "root","rajesh" to any other third persons.Now i dont want the dll function.Any one can say how to work with page?.I am waiting for encryption and decryption or any other methods also.But any way this username and password wont display others.Orelse any way to work with mysql server for this Quote Link to comment https://forums.phpfreaks.com/topic/72815-dbconnectphp/ Share on other sites More sharing options...
~n[EO]n~ Posted October 11, 2007 Share Posted October 11, 2007 Nobody will see this as long as you don't give the source file to other or tell the password and infos urself. The best way is to define the variables in a constant file and include that file in your connection page. For e.g I have a constant.php file , here i store my passwords and other things... define ('SERVERHOST','localhost' ); define ('SERVERUSER','myserver' ); define ('SERVERPASSWORD','c#nRnI_Ec$e' ); define ('SERVERDATABASE','myserverdb' ); define ('LOCALRHOST','localhost' ); define ('LOCALUSER','root' ); define ('LOCALPASSWORD','mylocalpwd' ); define ('LOCALDATABASE','mydb' ); And I have another file db.inc.php where I use those constants to connect. <?php // db.inc.php // connect to databse //-------- for Local Server-----------// $sLocalHost=LOCALRHOST; $sServerHost=SERVERHOST; $sLocalUser = LOCALUSER; $sLocalPassword = LOCALPASSWORD; $sServerUser = SERVERUSER; $sServerPassword = SERVERPASSWORD; $sServerDatabaseName = SERVERDATABASE; $sLocalDatabaseName = LOCALDATABASE; $conn = @mysql_connect($sServerHost,$sServerUser,$sServerPassword); if(!$conn) { $conn = mysql_connect($sLocalHost,$sLocalUser,$sLocalPassword); } //$con= mysql_connect("localhost","root"); //On Local Server $db=mysql_select_db($sServerDatabaseName); if(!$db){ $db=mysql_select_db($sLocalDatabaseName); } //----------------------------------------// if($conn=="") { trigger_error('Unable to connect to database: ' . mysql_error()); } ?> And then I have a config.php file where I include this connection .. and I include this config.php in all php pages that's all. Hope it helps Quote Link to comment https://forums.phpfreaks.com/topic/72815-dbconnectphp/#findComment-367227 Share on other sites More sharing options...
rajeshkumarvm Posted October 15, 2007 Author Share Posted October 15, 2007 Thank you for your kind replies Quote Link to comment https://forums.phpfreaks.com/topic/72815-dbconnectphp/#findComment-369796 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.