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. Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/ Share on other sites More sharing options...
fenway Posted August 6, 2008 Share Posted August 6, 2008 Anything specific? Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/#findComment-609581 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? Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/#findComment-610376 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. Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/#findComment-610743 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); ?> Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/#findComment-610804 Share on other sites More sharing options...
Andy-H Posted August 8, 2008 Author Share Posted August 8, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/118366-solved-best-practice/#findComment-611419 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.