{"id":1329,"date":"2020-02-18T11:09:16","date_gmt":"2020-02-18T10:09:16","guid":{"rendered":"https:\/\/www.wp-moon.com\/?p=1329"},"modified":"2020-02-18T11:45:54","modified_gmt":"2020-02-18T10:45:54","slug":"fatal-error-with-mysql_connect-after-upgrading-to-php-7","status":"publish","type":"post","link":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/","title":{"rendered":"Fatal error with mysql_connect after upgrading to PHP 7"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_custom_heading text=&#8221;Issue&#8221; use_theme_fonts=&#8221;yes&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]When you update your WordPress site under PHP 7, the following errors may appear :[\/vc_column_text][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<code>Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...wp-includes\/wp-db.php:1665<br \/>\nStack trace: #0 ...wp-includes\/wp-db.php(632): wpdb-&gt;db_connect() #1 ...wp-includes\/load.php(425)<br \/>\nFatal error: Uncaught Error: Call to undefined function wp_kses_normalize_entities() in ...\/wp-includes\/formatting.php:4316<br \/>\nStack trace: #0 ...\/wp-includes\/class-wp-fatal-error-handler.php(190)<\/code>[\/vc_column_text][\/vc_column][\/vc_row][vc_row][vc_column][vc_custom_heading text=&#8221;Where does this error come from?&#8221; use_theme_fonts=&#8221;yes&#8221;][vc_column_text]By upgrading to PHP 7.3 (or rather from PHP 7.0.0 onwards), the mysql_connect extension has been removed. It was already deprecated since PHP 5.5.0.<\/p>\n<p>Instead, it is recommended to use the mysqli extensions to connect to a database. This extension is more powerful and more secure.[\/vc_column_text][\/vc_column][vc_column][vc_custom_heading text=&#8221;What can be done to solve this problem?&#8221; use_theme_fonts=&#8221;yes&#8221;][vc_column_text]Depending on the origin of the error, there are several solutions:<\/p>\n<ul>\n<li>Contact your web host and ask if mysqli extensions are enabled.<\/li>\n<li>Check that you have mysqi enabled on your hosting:<br \/>\n<code>$var_mysqli = function_exists('mysqli_connect'); var_dump($var_mysqli);<\/code><\/li>\n<li>Test your connection with mysqli :<br \/>\n<code>$mysqli_connection = new MySQLi('nom_d_h\u00f4te', 'nom_utilisateur', 'mot_de_passe', 'nom_de_la_base_de_donn\u00e9es');<\/code><\/li>\n<li>Check your wp-config.php file and verify that the following variable :<br \/>\n<code>define(\u2018WP_USE_EXT_MYSQL\u2019, false);<\/code><br \/>\nis set to &#8220;false&#8221;.<\/li>\n<\/ul>\n<p>[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in &#8230;<\/p>\n","protected":false},"author":2,"featured_media":1262,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[51,52,53],"class_list":["post-1329","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fix-errors","tag-fatal-error-2","tag-mysql_connect-2","tag-php-7-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Fatal error with mysql_connect after upgrading to PHP 7 - WP Moon<\/title>\n<meta name=\"description\" content=\"When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Fatal error with mysql_connect after upgrading to PHP 7 - WP Moon\" \/>\n<meta property=\"og:description\" content=\"When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Moon\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpmoonwebsite\" \/>\n<meta property=\"article:published_time\" content=\"2020-02-18T10:09:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-02-18T10:45:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"359\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alexandre G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@alexgaboriau\" \/>\n<meta name=\"twitter:site\" content=\"@WPMoon4\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alexandre G\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Fatal error with mysql_connect after upgrading to PHP 7 - WP Moon","description":"When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/","og_locale":"en_US","og_type":"article","og_title":"Fatal error with mysql_connect after upgrading to PHP 7 - WP Moon","og_description":"When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...","og_url":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/","og_site_name":"WP Moon","article_publisher":"https:\/\/www.facebook.com\/wpmoonwebsite","article_published_time":"2020-02-18T10:09:16+00:00","article_modified_time":"2020-02-18T10:45:54+00:00","og_image":[{"width":640,"height":359,"url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg","type":"image\/jpeg"}],"author":"Alexandre G","twitter_card":"summary_large_image","twitter_creator":"@alexgaboriau","twitter_site":"@WPMoon4","twitter_misc":{"Written by":"Alexandre G","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#article","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/"},"author":{"name":"Alexandre G","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d"},"headline":"Fatal error with mysql_connect after upgrading to PHP 7","datePublished":"2020-02-18T10:09:16+00:00","dateModified":"2020-02-18T10:45:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/"},"wordCount":216,"commentCount":0,"publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg","keywords":["Fatal error","mysql_connect","PHP 7"],"articleSection":["Fix Errors"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/","url":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/","name":"Fatal error with mysql_connect after upgrading to PHP 7 - WP Moon","isPartOf":{"@id":"https:\/\/www.wp-moon.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#primaryimage"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#primaryimage"},"thumbnailUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg","datePublished":"2020-02-18T10:09:16+00:00","dateModified":"2020-02-18T10:45:54+00:00","description":"When you update your Wordpress site under PHP 7, the following errors may appear : Fatal error: Uncaught Error: Call to undefined function mysql_connect() in ...","breadcrumb":{"@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#primaryimage","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/wordpress-552924_640.jpg","width":640,"height":359},{"@type":"BreadcrumbList","@id":"https:\/\/www.wp-moon.com\/en\/fatal-error-with-mysql_connect-after-upgrading-to-php-7\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.wp-moon.com\/en\/"},{"@type":"ListItem","position":2,"name":"Fix Errors","item":"https:\/\/www.wp-moon.com\/en\/category\/fix-errors\/"},{"@type":"ListItem","position":3,"name":"Fatal error with mysql_connect after upgrading to PHP 7"}]},{"@type":"WebSite","@id":"https:\/\/www.wp-moon.com\/en\/#website","url":"https:\/\/www.wp-moon.com\/en\/","name":"WP Moon","description":"","publisher":{"@id":"https:\/\/www.wp-moon.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wp-moon.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.wp-moon.com\/en\/#organization","name":"WP Moon","url":"https:\/\/www.wp-moon.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2020\/02\/logo.png","width":290,"height":95,"caption":"WP Moon"},"image":{"@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/wpmoonwebsite","https:\/\/x.com\/WPMoon4"]},{"@type":"Person","@id":"https:\/\/www.wp-moon.com\/en\/#\/schema\/person\/72a64e6910977ec9e4b32fd8da54369d","name":"Alexandre G","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","url":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","contentUrl":"https:\/\/www.wp-moon.com\/wp-content\/uploads\/2023\/09\/312419460_10229483707296045_2919774527885824513_n-100x100.jpg","caption":"Alexandre G"},"description":"Alexandre, Web Developer &amp; Website Editor. I've been using WordPress for over 10 years in my professional environment and on personal projects. I created WP Moon to teach you how to use this CMS, solve your problems and show you all the tricks.","sameAs":["https:\/\/www.croque-pixel.com\/","https:\/\/x.com\/alexgaboriau","https:\/\/www.youtube.com\/@wp_moon\/videos"],"url":"https:\/\/www.wp-moon.com\/en\/author\/wp-moon\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/1329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/comments?post=1329"}],"version-history":[{"count":0,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/posts\/1329\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media\/1262"}],"wp:attachment":[{"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/media?parent=1329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/categories?post=1329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wp-moon.com\/en\/wp-json\/wp\/v2\/tags?post=1329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}