Jump to content
Science Forums

Connecting to MySQL Database


Recommended Posts

On connecting to MySQL database i know the function new mysqli is needed and the parameters are needed also for instance i have 4 parameters what does each parameters means ('localhost', 'bookorama', 'bookorama123', 'books').Are these the webserver or website address, username or password, databasename,table name.Correct me if i am wrong if my assumption on the following parameters needed to connect to MySQL database.Another question whats the difference of the configuration of MySQL database in the localhost compared to the webhosted.I mean the set up.Can i also include the name of my website as the first paramater of the function new mysqli? Thanks and hope you give me clarification on my questions thank you !!!!

Link to comment
Share on other sites

<? 
/*--------- DATABASE CONNECTION INFO---------*/ 
$hostname="localhost"; 
$mysql_login="myusername"; 
$mysql_password="mypassword"; 
$database="mydatabase"; 

// connect to the database server 
if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){ 
 die("Can't connect to database server.");     
}else{ 
 // select a database 
   if (!(mysql_select_db("$database",$db))){ 
     die("Can't connect to database."); 
   } 
} 
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...