Posted By

elvman on 08/17/11


Tagged


Versions (?)

Connect to MySQL database


 / Published in: PHP
 

  1. define('HOST', 'localhost');
  2. define('USER', 'root');
  3. define('PASS', 'root');
  4. define('DATABASE', 'analytics');
  5. define('ENCODING', 'utf8');
  6.  
  7. $database = mysql_connect(HOST, USER, PASS) or die(mysql_error());
  8. mysql_select_db(DATABASE, $database) or die(mysql_error());
  9.  
  10. mysql_query('SET NAMES '.ENCODING, $database) or die(mysql_error());

Report this snippet  

You need to login to post a comment.