PHP & MySQL Connect Script


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



Copy this code and paste it in your HTML
  1. <?php
  2. // This defines the constants for accessing the database
  3. define('db_user','username');
  4. define('db_password','password');
  5. define('db_host','localhost');
  6. define('db_name','database_name');
  7.  
  8. // Connect to MySQL
  9. $dbc = @mysql_connect (db_host, db_user, db_password) OR die ('Could not connect to MySQL: ' . mysql_error() );
  10. // Select the correct databse
  11. mysql_select_db (db_name) OR die ('Could not select the database: ' . mysql_error() );
  12.  
  13. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.