php無法連接mysqli怎麼辦

藏色散人
發布: 2023-03-17 12:34:01
原創
3480 人瀏覽過

php無法連接mysqli的解決方法:1.開啟「php.ini」檔案;2、找到「mysqli.reconnect」;3、將「mysqli.reconnect = OFF」改為「mysqli.reconnect = on”即可。

php無法連接mysqli怎麼辦

本教學操作環境:windows7系統、PHP8.1版、Dell G3電腦。

php無法連接mysqli怎麼辦?

PHP連接MySql,解決」Uncaught Error: Class 'mysqli' not found「問題

我的PHP是7.4的,但是mysql擴充好像是5以前的,我就只能用mysqli擴充來操作資料庫

我看了幾十篇回答,我的錯誤是phpinfo()頁面只有一個mysqlnd,沒有mysqli,所以網頁會報錯」Uncaught Error: Class 'mysqli' not found「

在php.ini裡

extension_dir = 「ext」也改成絕對路徑了,;extension=php_mysqli.dll前面的; 也去掉了,還是不行

最後發現下面這段

[MySQLi] ; Maximum number of persistent links. -1 means no limit. ; http://php.net/mysqli.max-persistent mysqli.max_persistent = -1 ; Allow accessing, from PHP’s perspective, local files with LOAD DATA statements ; http://php.net/mysqli.allow_local_infile ;mysqli.allow_local_infile = On ; Allow or prevent persistent links. ; http://php.net/mysqli.allow-persistent mysqli.allow_persistent = On ; Maximum number of links. -1 means no limit. ; http://php.net/mysqli.max-links mysqli.max_links = -1 ; Default port number for mysqli_connect(). If unset, mysqli_connect() will use ; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the ; compile-time value defined MYSQL_PORT (in that order). Win32 will only look ; at MYSQL_PORT. ; http://php.net/mysqli.default-port mysqli.default_port = 3306 ; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. ; http://php.net/mysqli.default-socket mysqli.default_socket = ; Default host for mysqli_connect() (doesn’t apply in safe mode). ; http://php.net/mysqli.default-host mysqli.default_host = ; Default user for mysqli_connect() (doesn’t apply in safe mode). ; http://php.net/mysqli.default-user mysqli.default_user = ; Default password for mysqli_connect() (doesn’t apply in safe mode). ; Note that this is generally a bad idea to store passwords in this file. ; Any user with PHP access can run 'echo get_cfg_var(“mysqli.default_pw”) ; and reveal this password! And of course, any users with read access to this ; file will be able to reveal the password as well. ; http://php.net/mysqli.default-pw mysqli.default_pw = ; Allow or prevent reconnect mysqli.reconnect = OFF
登入後複製

mysqli.reconnect = OFF改成mysqli.reconnect = on就行了,就很無語,有跟我狀況一樣的可以改改這個

推薦學習:《PHP影片教學

以上是php無法連接mysqli怎麼辦的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!