>  기사  >  백엔드 개발  >  PHP가 mysqli에 연결할 수 없으면 어떻게 해야 합니까?

PHP가 mysqli에 연결할 수 없으면 어떻게 해야 합니까?

藏色散人
藏色散人원래의
2022-11-09 10:07:083511검색

php가 mysqli에 연결할 수 없는 문제에 대한 해결 방법: 1. "php.ini" 파일을 엽니다. 2. "mysqli.reconnect"를 찾습니다. 3. "mysqli.reconnect = OFF"를 "mysqli.reconnect = on"으로 변경합니다. " .

PHP가 mysqli에 연결할 수 없으면 어떻게 해야 합니까?

이 튜토리얼의 운영 환경: Windows 7 시스템, PHP 버전 8.1, Dell G3 컴퓨터.

php가 mysqli에 연결할 수 없으면 어떻게 해야 하나요?

PHP는 "Uncaught Error: Class 'mysqli' notfound" 문제를 해결하기 위해 MySql에 연결합니다

내 PHP는 7.4인데 mysql 확장자가 5 이전인 것 같아서 mysqli 확장자를 통해서만 작동할 수 있습니다. 데이터베이스

수십 개의 답변을 읽었습니다. 제 실수는 phpinfo() 페이지에 mysqlnd가 하나만 있고 mysqli가 없다는 것입니다. 따라서 웹 페이지에서는 "Uncaught Error: Class 'mysqli' notfound"

in 오류를 보고합니다. .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 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.