Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $servername = "localhost";
- $username = "root";
- $password = "";
- $dbname = "tesddddt";
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- mysqli_set_charset($conn,"utf8");
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM customer";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- echo "id: " . $row["uid"]. " - Name: " . $row["username"]. " " . $row["email"]. "<br>";
- }
- } else {
- echo "0 results";
- }
- public function __construct(){
- try {
- $conn = new PDO("mysql:host=$this->db_host;dbname=$this->db_name", $this->db_user_name, $this->db_pass);
- mysqli_set_charset($conn,"utf8"); // <- added here
- $this->conn=$conn;
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $e)
- {
- echo "Connection failed: " . $e->getMessage();
- }
- }
- Warning: mysqli_set_charset() expects parameter 1 to be mysqli, object given in...
- $conn = new PDO("mysql:host=yourhost;dbname=yourdbname;charset=utf8");
- header("Content-Type: text/html; charset=utf-8");
- //header("Content-Type: text/html; charset=utf-8_general_ci");
- //error_reporting(E_ALL);
- ini_set('display_errors', true);
- set_time_limit(480);
- define("DSN", "mysql:host=localhost;dbname=biblewheel");
Add Comment
Please, Sign In to add comment