php無(wú)法連接mysqli的解決辦法:1、打開“php.ini”文件;2、找到“mysqli.reconnect”;3、將“mysqli.reconnect = OFF”改成“mysqli.reconnect = on”即可。
本教程操作環(huán)境:windows7系統(tǒng)、PHP8.1版、Dell G3電腦。
php無(wú)法連接mysqli怎么辦?
PHP連接MySql,解決 ”Uncaught Error: Class ‘mysqli‘ not found“問題
我的PHP是7.4的,但是mysql擴(kuò)展好像是5以前的,我就只能用mysqli擴(kuò)展來(lái)操作數(shù)據(jù)庫(kù)
立即學(xué)習(xí)“PHP免費(fèi)學(xué)習(xí)筆記(深入)”;
我看了幾十篇回答,我的錯(cuò)誤是phpinfo()頁(yè)面只有一個(gè)mysqlnd,沒有mysqli,所以網(wǎng)頁(yè)會(huì)報(bào)錯(cuò) ”Uncaught Error: Class ‘mysqli’ not found“
在php.ini里
extension_dir = “ext” 也改成絕對(duì)路徑了,;extension=php_mysqli.dll前面的 ; 也去掉了,還是不行
最后發(fā)現(xiàn)下面這段
[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就行了,就很無(wú)語(yǔ),有跟我情況一樣的可以改改這個(gè)
推薦學(xué)習(xí):《PHP視頻教程》
以上就是php無(wú)法連接mysqli怎么辦的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://www.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)