Guest User

Untitled

a guest
Jun 29th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. <?php
  2.  
  3. $dbname = "db";
  4. $dbuser = "dbuser";
  5. $dbpass = "dbpassword";
  6. $dbhost = "mysql.localhost.com";
  7.  
  8.  
  9. $db_con = mysql_connect($dbhost, $dbuser, $dbpass);
  10.  
  11. if(!$db_con) {
  12.     die("MYSQL FAILED TO CONNECT. BOOHOO");
  13. }
  14.  
  15. mysql_select_db($dbname, $db_con);
  16.  
  17. // this gets the current count
  18. $res = mysql_query("SELECT id FROM HitCounter");
  19. $row = mysql_fetch_row($res);
  20. echo "Hit's before incr: ".$row[0]."<br />";
  21.  
  22. // this increments the count
  23. // NOTE: Do NOT use this table for more than one counter. Ie only MyFunkyButton
  24.  
  25. $res = mysql_query("REPLACE INTO HitCounter (name) VALUES('MyFunkyButton');");
  26. echo "Total Hits: ".mysql_insert_id($db_con);
  27.  
  28. mysql_close($db_con);
Add Comment
Please, Sign In to add comment