Jump to content

cutepraba

New Members
  • Posts

    3
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

cutepraba's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for the explanation. I have changed my codes to class secondclass { private $db; public function __construct() { global $obj_db; $this->db = $obj_db; } public function selectDetails($id){ $sql = 'some sql here'; return dbconnect::query($sql)->rows; } TO public function selectDetails($id){ $sql = 'some sql here'; return $this->db->query($sql)->rows; } Is there anyway to retain dbconnect::query; without replacing to new?
  2. I am using parent::__construct() in almost every classes to connect Mysql DB. Example class class secondClass extends dbconnect { public function __construct() { parent::__construct(); dbconnect class class dbconnect { private $mysqli_handler; public function __construct() { try { mysqli_report(MYSQLI_REPORT_STRICT); $this->mysqli_handler = mysqli_connect(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DBNAME); } catch (mysqli_sql_exception $e) { throw new Exception('Error: Could not make a database link using ' . DB_USERNAME . '@' . DB_HOSTNAME . '!'); } if ($this->mysqli_handler->connect_error) { trigger_error('Error: Could not make a database link (' . $this->mysqli_handler->connect_errno . ') ' . $this->mysqli_handler->connect_error); } $this->mysqli_handler->query("SET NAMES 'utf8'"); $this->mysqli_handler->query("SET CHARACTER SET utf8"); $this->mysqli_handler->query("SET CHARACTER_SET_CONNECTION=utf8"); $this->mysqli_handler->query("SET SQL_MODE = ''"); $this->mysqli_handler->query("SET time_zone = 'Asia/Kolkata'"); } Is this create multiple instance of mysql dbconnection? I am frequently getting mysql connection error on my shared hosting. If so how to avoid? I am using PHP Version 7.4.16, some detailed explanation will be useful for me as I am using like this for many projects. Thank you for your time. Prabakaran
  3. $name = $name . "<option value=". $row['name'] . ">" .$row['name'] . "</option>"; but the name is "Mr. Robert",it does have dot symbol...how to overcome? please help
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.