codecruiser9999 Posted January 8, 2009 Report Posted January 8, 2009 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 !!!! Quote
Tormod Posted January 8, 2009 Report Posted January 8, 2009 <? /*--------- 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."); } } ?> Quote
alexander Posted January 8, 2009 Report Posted January 8, 2009 oh i wouldn't use a persistent connection like that without proper closing of it, T :shrug: but that illustrates the functionality just fine :) Quote
Tormod Posted January 8, 2009 Report Posted January 8, 2009 Good point. I just copied that from somewhere... :shrug: Quote
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.