DamienG Posted January 13, 2010 Share Posted January 13, 2010 Hi, When connecting yo a MySql database I do the following witch works <?php //information $host = 'localhost'; $user = 'root'; $pass = ''; $db = 'db'; //connect $connect = @mysql_connect ($host,$user,$pass) or die (mysql_error () ); $select = @mysql_select_db ($db, $connect) or die (mysql_error () ) ?> Now last time I checked that works, is that the best way to do it? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/188369-connecting/ Share on other sites More sharing options...
mikesta707 Posted January 13, 2010 Share Posted January 13, 2010 as far as mysql goes, thats pretty much the only way to connect to a database. A lot of people make the database info (like $host, $user, etc) into constants rather than normal variables, but beyond that yeah, thats how you do it Quote Link to comment https://forums.phpfreaks.com/topic/188369-connecting/#findComment-994420 Share on other sites More sharing options...
DamienG Posted January 13, 2010 Author Share Posted January 13, 2010 Thanks, It's just I have seen people do it different ways and I was hoping my way was okay Quote Link to comment https://forums.phpfreaks.com/topic/188369-connecting/#findComment-994534 Share on other sites More sharing options...
faco Posted January 13, 2010 Share Posted January 13, 2010 depends on what and how you wanna connect to db in your files. you can put it all in some xy.php and inside create a function which hits the connect querry. then in next .php just include the xy file and write the name of the connecting function... but the process of connecting like this is the correct one! Quote Link to comment https://forums.phpfreaks.com/topic/188369-connecting/#findComment-994539 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.