Posted By

ginoplusio on 02/01/10


Tagged

mysql php db mysqli connect


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

ginoplusio


MySQLi connection


 / Published in: PHP
 

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

  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. }

Report this snippet  

You need to login to post a comment.