Andy-H Posted August 6, 2008 Share Posted August 6, 2008 What is the best practice for connecting to, selecting and querying a database in MySQL. Thanks for any replies. Quote Link to comment Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 Anything specific? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 7, 2008 Author Share Posted August 7, 2008 Just for a text based MORPG? Quote Link to comment Share on other sites More sharing options...
fenway Posted August 7, 2008 Share Posted August 7, 2008 Just for a text based MORPG? That's not really specific... I mean a specific question about how to query. Quote Link to comment Share on other sites More sharing options...
SeanHarding Posted August 7, 2008 Share Posted August 7, 2008 I guess the best practise would be to have your connect to the database password behind your DNS wall. <?php # connect.php DEFINE ('DB_USER', 'username'); DEFINE ('DB_PASSWORD', 'yourpassword'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', databasename); $connect = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('Could not connect to MySQL: ' . mysqli_connect_error()); ?> The in your main DNS page use <?php require_once('../connect.php') $what = "SELECT * bla bla bla"; $query = mysqli_query($connect, $what); // dont forget to close connection! mysqli_close($connect); ?> Quote Link to comment Share on other sites More sharing options...
Andy-H Posted August 8, 2008 Author Share Posted August 8, 2008 thanks Quote Link to comment 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.