Connect to MySQL database


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.