php 数据库连接 编码设置问题
我先在本地运行PHP网站,环境已经搭配好啦,数据库也导进去啦,在IIS 浏览时出现错误,弹出一个提示框,“.$str.”
错误就是这段。有没有大神帮忙看看。
public function show_error($message='',$sql=''){
echo "
}
回复讨论(解决方案)
代码贴出来....
代码贴出来....
能帮忙看看吗?搞一上午了这个问题。
你先截个图看看,感觉不是你认为的地方
把你那块的代码拿来看看,你那段错误信息没有明显的指出错误的地方
把你那块的代码拿来看看,你那段错误信息没有明显的指出错误的地方
这是数据库连接的那段代码!
class mysql{
private $db_host;
private $db_user;
private $db_pwd;
private $db_database;
private $conn;
private $sql;
private $result;
private $coding;
private $show_error = true;
public function __construct($db_host="localhost", $db_user="root", $db_pwd="admin", $db_database="likang", $coding = 'utf-8'){
$this->db_host = $db_host;
$this->db_user = $db_user;
$this->db_pwd = $db_pwd;
$this->db_database = $db_database;
$this->coding = $coding;
$this->connect();
}
private function connect(){
$this->conn = @mysql_connect($this->db_host,$this->db_user,$this->db_pwd);
if(!$this->conn){
if($this->show_error){
$this->show_error('错误提示:链接数据库失败!');
}
}
if(!@mysql_select_db($this->db_database, $this->conn)){
if($this->show_error){
$this->show_error('错误提示:打开数据库失败!');
}
}
if(!@mysql_query("SET NAMES $this->coding")){
if($this->show_error){
$this->show_error('错误提示:设置编码失败!');
}
}
}
public function query($sql){
$this->sql = $sql;
$result = mysql_query($this->sql, $this->conn);
if(!$result){
$this->show_error('错误的SQL语句:', $this->sql);
}else{
return $this->result = $result;
}
}
public function close()
{
return mysql_close();
} //关闭数据库连接
public function show_databases(){
$this->query("show databases");
echo '现有数据库:' . mysql_num_rows($this->result);
echo "
";
$i = 1;
while($row=mysql_fetch_array($this->result)){
echo "$i $row[Database]" . "
";
$i++;
}
}
public function show_tables(){
$this->query("show tables");
echo "数据库{$this->db_database}共有". mysql_num_rows($this->result) . "张表:";
echo "
";
$column_name = "Tables_in_" . $this->db_database;
$i = 1;
while($row=mysql_fetch_array($this->result)){
echo "$i $row[$column_name]" . "
";
$i++;
}
}
public function fetch_array($result=''){
if($this->result){
return mysql_fetch_array($this->result);
}else{
return mysql_fetch_array($result);
}
}
public function findall($table, $field = '*') {
return $this->query("SELECT $field FROM $table");
}
public function delete($table, $condition) {
return $this->query("DELETE FROM $table WHERE $condition");
}
public function insert($table, $field, $value) {
$i= $this->query("INSERT INTO $table ($field) VALUES ('$value')");
return $i;
}
public function update($table, $update_content, $condition) {
// echo "UPDATE $table SET $update_content WHERE $condition";
return $this->query("UPDATE $table SET $update_content WHERE $condition");
}
public function insert_id() {
return mysql_insert_id();
}
public function num_rows() {
if ($this->result == null) {
if ($this->show_error) {
$this->show_error('SQL语句错误', '请检查是否已经使用了query()方法,并成功查询且返回了资源标识符?');
}
} else {
return mysql_num_rows($this->result);
}
}
public function num_fields($table) {
$this->query("select * from $table");
echo "
";
echo '字段数:' . $total = mysql_num_fields($this->result);
echo "
"; <br> for ($i = 0; $i print_r(mysql_fetch_field($this->result, $i)); <br> } <br> echo "
echo "
";
}
public function show_error($message='',$sql=''){
echo "";
}
}
?>
你先截个图看看,感觉不是你认为的地方
我点击index.php 的时候它出来的是数据库连接的代码和两个连着弹窗 “.$str.”,弹窗的后面就是我贴上的那段代码其中这块显示红色
public function show_error($message='',$sql=''){
echo "
点完 确定 就显示无法找个该页的。
这是PHP配置环境 mysql没有值 跟这个有关系吗?wordpress phpMyAdmin 都装了 这些地方都没有问题。

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

記事本++7.3.1
好用且免費的程式碼編輯器

SublimeText3漢化版
中文版,非常好用

禪工作室 13.0.1
強大的PHP整合開發環境

Dreamweaver CS6
視覺化網頁開發工具

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

JWT是一種基於JSON的開放標準,用於在各方之間安全地傳輸信息,主要用於身份驗證和信息交換。 1.JWT由Header、Payload和Signature三部分組成。 2.JWT的工作原理包括生成JWT、驗證JWT和解析Payload三個步驟。 3.在PHP中使用JWT進行身份驗證時,可以生成和驗證JWT,並在高級用法中包含用戶角色和權限信息。 4.常見錯誤包括簽名驗證失敗、令牌過期和Payload過大,調試技巧包括使用調試工具和日誌記錄。 5.性能優化和最佳實踐包括使用合適的簽名算法、合理設置有效期、

會話劫持可以通過以下步驟實現:1.獲取會話ID,2.使用會話ID,3.保持會話活躍。在PHP中防範會話劫持的方法包括:1.使用session_regenerate_id()函數重新生成會話ID,2.通過數據庫存儲會話數據,3.確保所有會話數據通過HTTPS傳輸。

SOLID原則在PHP開發中的應用包括:1.單一職責原則(SRP):每個類只負責一個功能。 2.開閉原則(OCP):通過擴展而非修改實現變化。 3.里氏替換原則(LSP):子類可替換基類而不影響程序正確性。 4.接口隔離原則(ISP):使用細粒度接口避免依賴不使用的方法。 5.依賴倒置原則(DIP):高低層次模塊都依賴於抽象,通過依賴注入實現。

在PHPStorm中如何進行CLI模式的調試?在使用PHPStorm進行開發時,有時我們需要在命令行界面(CLI)模式下調試PHP�...

PHP8.1中的枚舉功能通過定義命名常量增強了代碼的清晰度和類型安全性。 1)枚舉可以是整數、字符串或對象,提高了代碼可讀性和類型安全性。 2)枚舉基於類,支持面向對象特性,如遍歷和反射。 3)枚舉可用於比較和賦值,確保類型安全。 4)枚舉支持添加方法,實現複雜邏輯。 5)嚴格類型檢查和錯誤處理可避免常見錯誤。 6)枚舉減少魔法值,提升可維護性,但需注意性能優化。

如何在系統重啟後自動設置unixsocket的權限每次系統重啟後,我們都需要執行以下命令來修改unixsocket的權限:sudo...

靜態綁定(static::)在PHP中實現晚期靜態綁定(LSB),允許在靜態上下文中引用調用類而非定義類。 1)解析過程在運行時進行,2)在繼承關係中向上查找調用類,3)可能帶來性能開銷。
