Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. # Database connection
  2.  
  3. To store data, you would need a database. In this case we would be using MySQL database.
  4.  
  5. ```php
  6. <?php
  7. $DBNAME = 'dbname';
  8. $HOST = 'localhost';
  9. $DBUSER = 'dbuser';
  10. $DBPASS = 'dbpass';
  11.  
  12. $CONNECT = mysql_connect($HOST,$DBUSER,$DBPASS);
  13. if(!$CONNECT) {
  14. echo 'MySQL Error: '.mysql_error();
  15. }
  16.  
  17. $SELECT = mysql_select_db($DBNAME);
  18. if(!$SELECT) {
  19. echo 'MySQL Error: '.mysql_error();
  20. }
  21. ?>
  22. ```
  23.  
  24. In the highlighted lines above, you would have to specify your own server database details.
  25.  
  26. You can save the above file as config.php and you would have to include that file in all pages where you need database connectivity.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement