MySQLi connection


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



Copy this code and paste it in your HTML
  1. define("WEBDOMAIN", "your host");
  2. define("DEFDBNAME", "your db name");
  3. define("DEFUSERNAME", "your user");
  4. define("DEFDBPWD", "your pwd");
  5.  
  6. if(!$conn = connectDb()) {die("err db");} else {$conn->query("SET NAMES 'utf8';");}
  7.  
  8. function connectDb() {
  9. if ($conn = @new mysqli(WEBDOMAIN, DEFUSERNAME, DEFDBPWD, DEFDBNAME)) return $conn; else return false;
  10. }

URL: http://www.barattalo.it/2010/01/29/10-php-usefull-functions-for-mysqli-improved-stuff/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.