Creating PHP Connection to MySQL Table


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



Copy this code and paste it in your HTML
  1.  
  2. <?php
  3.  
  4. $connection = mysql_connection('localhost','username','password');
  5. // three parameters (server connection, username, password
  6.  
  7. //testing connection
  8. //concatenates the mysql_error() call to the string
  9. if(!$connection){
  10. die('error connection to database server'.mysql_error());
  11. }
  12. //checks to see if connected to proper database
  13. if(!mysql_select_db('database_name',)){
  14. die('error connection to database');
  15. }
  16.  
  17. ?>
  18.  
  19.  
  20.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.