当前位置: 首页>>代码示例>>PHP>>正文


PHP mysqli::character_set_name方法代码示例

本文整理汇总了PHP中mysqli::character_set_name方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::character_set_name方法的具体用法?PHP mysqli::character_set_name怎么用?PHP mysqli::character_set_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mysqli的用法示例。


在下文中一共展示了mysqli::character_set_name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  * 
  * @param String  $server     
  * @param String  $database   
  * @param String  $dbuser     
  * @param String  $dbpassword 
  * @param boolean $debug      Mostra tota la informació de les peticions SQL.
  */
 public function __construct($server, $database, $dbuser, $dbpassword, $debug = false)
 {
     $this->setDebug($debug);
     if (!empty($server) && !empty($database) && !empty($dbuser) && !empty($dbpassword)) {
         $this->dbg('Connection', 'Intentant connectar amb el servidor.');
         //
         $mysqli = new mysqli($server, $dbuser, $dbpassword, $database);
         /* comprobar la conexió */
         if ($mysqli->connect_errno) {
             $this->dbg('Connection', "Falló la conexión: %s\n", $mysqli->connect_error);
             exit;
         }
         $this->dbg('Connection', 'Connexió correcte (OK)');
         /* cambiar el conjunto de caracteres a utf8 */
         if (!$mysqli->set_charset("utf8")) {
             $this->dbg('Connection', "Error cargando el conjunto de caracteres utf8: %s\n", $mysqli->error);
         } else {
             $this->dbg('Info', "Conjunt de caracteres actual: " . $mysqli->character_set_name());
         }
         //
         $this->db = $mysqli;
     } else {
         $this->dbg('info', 'Database no inicialitzada');
     }
 }
开发者ID:jherediagu,项目名称:krang_framework,代码行数:34,代码来源:DBA.php

示例2: __construct

 public function __construct($dsn = "", $user = "", $passwd = "", $chrset = "utf8")
 {
     #데이타베이스 접속
     if (!empty($dsn)) {
         $dsn_args = explode(":", $dsn);
         parent::__construct($dsn_args[0], $user, $passwd, $dsn_args[1]);
     } else {
         //config.inc.php --> config.db.php
         parent::__construct(_DB_HOST, _DB_USER, _DB_PASSWD, _DB_NAME);
     }
     if (mysqli_connect_error()) {
         throw new ErrorException(mysqli_connect_error(), mysqli_connect_errno());
     }
     #문자셋
     $chrset_is = parent::character_set_name();
     if (strcmp($chrset_is, $chrset)) {
         parent::set_charset($chrset);
     }
 }
开发者ID:kisstest,项目名称:snu_stress_manage,代码行数:19,代码来源:DbMysqli.class_20150814.php

示例3: db_connect

function db_connect($mysql_host, $mysql_user, $mysql_password, $database)
{
    $db_con = new mysqli($mysql_host, $mysql_user, $mysql_password, $database);
    /* check connection */
    if ($db_con->connect_errno) {
        printf("<p><span class='red'>&nbsp;MySQL Connect failed: %s\n&nbsp;<br /></span></p>", $db_con->connect_error);
    }
    if (!$db_con->connect_errno) {
        /* define character set to utf8 */
        if (!$db_con->set_charset("utf8")) {
            printf("Error loading character set utf8: %s\n", $db_con->error);
            /* Print current character set */
            $charset = $db_con->character_set_name();
            printf("<br />Current character set is: %s\n", $charset);
            $db_con->close();
            exit;
        }
    }
    return $db_con;
}
开发者ID:hackersforcharity,项目名称:rachelpiOS,代码行数:20,代码来源:commonfuncs.php

示例4: mysqli

<?php

$basedatos = "liberacioncelular";
$host = '130.211.174.74';
$user = 'root';
$pass = 'alfonso2110';
$port = null;
$socket = '';
/*
$host=null;
$user='root';
$pass='';
$port=null;
$socket='/cloudsql/control-asx:control-db';
*/
$mysqli = new mysqli($host, $user, $pass, $basedatos, $port, $socket);
/* verificar la conexión */
if (mysqli_connect_errno()) {
    printf("Falló la conexión failed: %s\n", $mysqli->connect_error);
    exit;
}
if ('utf8' != $mysqli->character_set_name()) {
    if (!$mysqli->set_charset("utf8")) {
        printf("Error cargando el conjunto de caracteres utf8: %s\n", $mysqli->error);
        exit;
    } else {
        printf("Conjunto de caracteres actual: %s\n", $mysqli->character_set_name());
    }
}
开发者ID:unPoncho,项目名称:control-asx,代码行数:29,代码来源:db.php

示例5: mysqli

<?php

$host = 'localhost';
$database = 'test';
$username = 'root';
$password = 'root';
$selectName = 'harry';
//要查找的用户名,一般是用户输入的信息
$insertName = 'testname';
// 创建对象并打开连接,最后一个参数是选择的数据库名称
$mysqli = new mysqli($host, $username, $password, $database);
// 编码转化为 utf8
if (!$mysqli->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $mysqli->error);
} else {
    printf("Current character set: %s\n", $mysqli->character_set_name());
}
if (mysqli_connect_errno()) {
    // 诊断连接错误
    die("could not connect to the database.\n" . mysqli_connect_error());
}
$selectedDb = $mysqli->select_db($database);
//选择数据库
if (!$selectedDb) {
    die("could not to the database\n" . mysql_error());
}
if ($stmt = $mysqli->prepare("select * from user where name = ?")) {
    /* bind parameters for markers */
    $stmt->bind_param("s", $selectName);
    /* execute query */
    $stmt->execute();
开发者ID:CraryPrimitiveMan,项目名称:code-examples,代码行数:31,代码来源:mysqli.php

示例6: mysqli

$zapisovy_ffmpeg_audio_channels = $_POST["odeslane_ffmpeg_audio_channels"];
$zapisovy_ffmpeg_audio_sampling = $_POST["odeslane_ffmpeg_audio_sampling"];
$zapisovy_csfd_title_cesky = str_replace("'", "\\'", $zapisovy_csfd_title_cesky);
$zapisovy_csfd_title_original = str_replace("'", "\\'", $zapisovy_csfd_title_original);
$zapisovy_csfd_description = str_replace("'", "\\'", $zapisovy_csfd_description);
$servername = "127.0.0.1";
$username = "jakubkrizka.cz";
$password = "tnqBY26Y";
$dbname = "jakubkrizkacz1";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
if (!$conn->set_charset("utf8")) {
    printf("Error loading character set utf8: %s\n", $conn->error);
} else {
    printf("Current character set: %s\n", $conn->character_set_name());
}
$sql = "INSERT INTO csfd (\n   id,\n   title_original,\n   title_cesky, \n   year, \n   genre, \n   url, \n   description)\nVALUES (\n   '{$zapisovy_ffmpeg_id_csfd}', \n   '{$zapisovy_csfd_title_original}', \n   '{$zapisovy_csfd_title_cesky}', \n   '{$zapisovy_csfd_year}', \n   '{$zapisovy_csfd_genre}', \n   '{$zapisovy_csfd_url}', \n   '{$zapisovy_csfd_description}')";
if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>

</body>
</html>
开发者ID:JakubKrizka,项目名称:homepage-02,代码行数:31,代码来源:step4.php

示例7: ConnectBD

 public function ConnectBD($pSERVIDOR, $pUSUARIO, $pPASSWORD, $pBD, $pPORT, $pCHARSET)
 {
     // Conectarse a la BD o no
     $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, "Connect Server: " . $pSERVIDOR . " - User: " . $pUSUARIO);
     // Conectarse a la Base de Datos
     $r = new mysqli($pSERVIDOR, $pUSUARIO, $pPASSWORD, $pBD, $pPORT);
     if (mysqli_connect_errno()) {
         $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, mysqli_connect_error());
         $this->sysKrn->krn_do_json($pSTATUS = FALSE, $pPARAM_1 = ERR_DB_CONNECTION_FAIL, $pPARAM_2 = "mysqli_connect_error ()");
     }
     // cambiar el conjunto de caracteres a utf8
     if (!$r->set_charset($pCHARSET)) {
         $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, "Charset Error - Server: " . $pSERVIDOR . " - Error Character Set: " . $r->error);
     } else {
         $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, "Charset ok - Server: " . $pSERVIDOR . " - Character Set: " . $r->character_set_name());
     }
     // Comprobarmos si existen las tablas
     $CHECK_TABLES_LENGTH = count($this->sysCheckTables);
     for ($i = 0; $i < $CHECK_TABLES_LENGTH; $i++) {
         if (mysqli_query($r, "DESCRIBE `" . $this->sysCheckTables[$i] . "`")) {
             $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, " Table: " . $this->sysCheckTables[$i] . ": ok");
         } else {
             $this->sysKrn->krn_audit_log(AUDIT_DB, __DIR__, __FILE__, __LINE__, __CLASS__, __METHOD__, __FUNCTION__, " Table: " . $this->sysCheckTables[$i] . ": not exists");
             $this->sysKrn->krn_do_json($pSTATUS = FALSE, $pPARAM_1 = ERR_DB_CHECK_TABLES_FAIL, $pPARAM_2 = " Table: " . $this->sysCheckTables[$i] . ": not exists");
         }
     }
     return $r;
 }
开发者ID:jneivil,项目名称:api,代码行数:28,代码来源:sysBDEngine.php

示例8: define

        $Config['MySQL'] = $Config['URL']['Other'][$_Server]['MySQL'];
        $Config['Lang'] = $Config['URL']['Other'][$_Server]['Lang'];
        define("SERVER", $Config['URL']['Other'][$_Server]["Require.www"] ? "http://www." . $_Server : "http://" . $_Server);
        define("HOST", $Config['URL']['Other'][$_Server]["Require.www"] ? "www." . $_Server : $_Server);
        define("sSERVER", $Config['URL']['Other'][$_Server]["SSL.enabled"] ? "https://" . HOST : "http://" . HOST);
    } elseif (!empty($Config['URL']["Default"]["Server"])) {
        $Config['Lang'] = $Config['URL']['Default']['Lang'];
        define("SERVER", $Config["URL"]["Default"]["Require.www"] ? "http://www." . $Config['URL']["Default"]["Server"] : "http://" . $Config['URL']["Default"]["Server"]);
        define("HOST", $Config["URL"]["Default"]["Require.www"] ? "www." . $Config['URL']["Default"]["Server"] : $Config['URL']["Default"]["Server"]);
        define("sSERVER", $Config["URL"]["Default"]["SSL.enabled"] ? "https://" . HOST : "http://" . HOST);
    } else {
        echo "You don´t have access.";
        exit;
    }
} else {
    exit;
}
$MySQLi = new mysqli($Config['MySQL']["host"], $Config['MySQL']["user"], $Config['MySQL']["pass"], $Config['MySQL']["dbname"]);
if ($MySQLi->connect_error) {
    die('Error de Conexión MySQLi (' . $MySQLi->connect_errno . ') ' . $mysqli->connect_error);
}
$_mysqliCharacter = $MySQLi->character_set_name();
require 'Class.Core.php';
$Core = new Core();
require 'Class.Users.php';
$Users = new Users();
// AntiHTML & SQL Injection
$_POST = str_replace(['<', '>', '\'', '\'', '\\'], ['&lt;', '&gt;', '&quot;', '&#39;', '&#92;'], $_POST);
$_GET = str_replace(['<', '>', '\'', '\'', '\\'], ['&lt;', '&gt;', '&quot;', '&#39;', '&#92;'], $_GET);
DEFINE('FILES', KERNEL . 'Files/' . DIRECTORY_SEPARATOR . $Config['Lang'] . DIRECTORY_SEPARATOR);
DEFINE('GLOBALS', FILES . '/GLOBAL/');
开发者ID:53SPARTA53,项目名称:DoPs,代码行数:31,代码来源:Init.php

示例9: getCharset

 /**
  * Возвращает кодировку по умолчанию, установленную для соединения с БД.
  *
  * @param void
  * @return string
  */
 public function getCharset()
 {
     return $this->mysqli->character_set_name();
 }
开发者ID:project-hh,项目名称:Database,代码行数:10,代码来源:Mysql.php

示例10: mysqli

 * @version 1.0
 * @author Linea de Codigo (http://lineadecodigo.com)
 * @date   19-mayo-2013
 * @url    http://lineadecodigo.com/php/cambiar-el-charset-en-la-conexion-a-mysql/
 * @description C—digo que nos muestra como cambiar el charset en la conexi—n a una base de datos MySQL, para cambiarlo de latin1 a utf8..
 */
?>


<!doctype html>
<html>
<head><title>Especificar Charset al conectarnos a una Base de Datos</title>
</head>
<body>
<h1>Especificar Charset al conectarnos a una Base de Datos</h1>


<?php 
@($db = new mysqli(localhost, "root", "", "biblioteca"));
if ($db->connect_error) {
    die('Error de Conexion (' . $db->connect_errno . ')' . $db->connect_error);
}
echo "Conexion correcta con la base de datos... <br>" . $db->host_info . "<br>";
echo "Utilizando un charset, por defecto, de tipo: " . $db->character_set_name() . "<br>";
$db->set_charset('utf8');
echo "Utilizando un nuevo charset de tipo: " . $db->character_set_name();
$db->close();
?>

</body>
</html>
开发者ID:alicano31,项目名称:lineadecodigo,代码行数:31,代码来源:especificar-charset-db.php


注:本文中的mysqli::character_set_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。