Scenario
I had installed php8 and wordpress 5.6 locally over my computer.
Problem
When I run the wordpress, I get Fatal Error.
Question
Anyone of you facing the same problem and how did you solve it? Thanks
Your PHP 8 installation does not have a mysqli extension installed.
See possible dupe: Wordpress Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /wp-includes/wp-db.php:1570
I kind of wish WordPress would tell you explicitly that it's missing a usable database extension. The major indicator is the error message itself where WordPress tries to call mysql_connect which was removed ages ago.
WordPress 5.6 core appears to run correctly on PHP 8. Though, the same might not be true of plugins (yet), so you'll want to test them individually.
[Edit] WordPress's database abstraction is written to use either the mysql or mysqli extensions, but the mysql extension was removed in PHP 7.0. The abstraction library does not support PDO, so even if you have the PDO MySQL driver, WordPress will not use it.
Edit: And to demonstrate a reproduction of the error, I took the same install, but rebuilt my Docker image without the mysqli extension:
Related
i was updating my production server with php 8 and i discovered an error "Fatal Error: Class mysqli not found". So i asked to the support and they told me that "according to php official manual, mysqli is not supported anymore in php 8".
I tried to find any news on the internet about this, but i can't find anything.
Looking at the php changelog, they talk about bugfixes for mysqli library until PHP 8.0.2, then nothing.
Looking at the MySQLi official page on the php manual, there is only "PHP5, PHP7" as supported (while there is PHP 8 on PDO instead).
So, has somebody any news about this? What happened?
I got the same problem installing Wamp Server on a local machine with PHP 8.0.6, so i think they really removed MySQLi from the library, but in both local and production doing a phpinfo() i can clearly see "mysqli" extension installed.
Thank you in advance.
EDIT:
About the production server, basically, provider told me "use sp-php instead of php", and now mysqli works.
About the PHP.net, i think they forgot to add the support.
It's just a documentation problem. There's a pull request to add PHP/8 to the supported versions but it hasn't made its way to live yet.
mysqli is still supported with php ≥8.
In my Ubuntu (22.04) for example, it was not included in the distribution. You can install it at any time with:
sudo apt-get install php-mysqlnd
After rebooting php, everything works as expected.
Hope this helps
I have twig installed via composer on a new codebase I'm working on (OSX), and on a new server I was trying install my app on. I started getting a fatal error on twig_template_get_attributes()
namely
PHP Fatal error: Call to undefined function twig_template_get_attributes() in /<path_to_here>/templates_c/a2/4e/3fbd69b54a0875d7cd3744d62bf1fa98ed4e7b1b375f904ead10b7cb27b6.php
I don't have this problem locally (OSX), and I was trying figure out why this is happening on my other server (Ubuntu 12.04 if that matters). When I install twig as a PHP extension the problem goes away, but my understanding is that the extension is completely optional and only optimizes one call
as per the documentation
The C extension is optional but it brings some nice performance
improvements. Note that the extension is not a replacement for the PHP
code; it only implements a small part of the PHP code to improve the
performance at runtime; you must still install the regular PHP code.
and
And from now on, Twig will automatically compile your templates to
take advantage of the C extension. Note that this extension does not
replace the PHP code but only provides an optimized version of the
Twig_Template::getAttribute() method.
very confused about this behavior.
I am very new to web development but am required to use iis 7 and php to pull data from a remote mysql database to be displayed in a series of webpages.
I installed iis 7 along with php fine and can run phpinfo() through a .php file from a browser by going to localhost/testphp.php , however, when I tried to connect to a mysql server using the function mysql_connect in another .php file I got the error in the title.
I am running php 5.6.15 and can't find much in the way of an answer for this.
I also don't seem to have a php.ini file (let alone know if I should have one) and phpinfo() tells me that my loaded configuration file is "(none)".
I'm at my wit's end trying to find a solution to this with as little experience as I have. Does anyone know how to solve this problem? If so I would much appreciate any help I can get.
Thank you!
As of PHP 5.5, MySQL is deprecated. http://php.net/manual/en/migration55.deprecated.php
You should go for alternative ( MySQLi for example ), or use older version of PHP.
As mentioned a couple of times the old MySQL stuff is deprecated. I would actually suggest looking at PDO instead of MySQLi too.
To check for the API you are wanting, check for the following in phpinfo():
Should be a section called "mysql" with something like:
First of all, I am a novice web developer.
My question is "A website developed with PHP 5.4 can run on PHP 5.3 configured server?"
(Detail Description)
I configure myself Apache 2.4, MySQL 5.6 and PHP 5.4.12 on Windows. Everything's ok. But the errors occur when I changed my website folder to another machine which is configured with WAMPserver. This WAMPserver is configured with Apache 2.2.11, PHP 5.3 and MySQL 5.1.36.
I install MySQL 5.6 on this machine and database is successfully connected. But the "Parse error occur to the code" such as
$country = mysql_fetch_row(queryMySQL("----"))[0];
In addition, it showed other errors such as "Table 'emp.productcateogry' doesn't exist".
Please, give me some suggestions.
The short answer is: no, you should not expect it to, especially if using the new features of PHP 5.4 within your code.
The specific error you are referring to with:
Parse error occur to the code
is because the line
$country = mysql_fetch_row(queryMySQL("----"))[0];
is using the new feature:
Function array dereferencing
Which, prior to PHP 5.4, had to use a temporary variable in order to access a specific index of the return, ie:
$country_temp = mysql_fetch_row(queryMySQL("----"));
$country = $country_temp[0];
Now, being that you are a novice developer, there are a few things you should note. The first and most important being that mysql_ functions are deprecated giving the note:
This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.
In other words, use PDO if wanting to use prepared statements, or MySQLi if not. Another advantage of using PDO and obtaining only one column as you are in the example code is that once you are connected, you can use the function PDOStatement::fetchColumn() to obtain only one column like you are trying to do now.
Anyways, I hope this explanation helps you understand why you can't go back to PHP 5.3.x if using specific PHP 5.4 abilities - and also some understanding of how to improve your database connection and available functions that can help you get your desired result without using the "array dereferencing" that is provided with PHP 5.4. ^^
I have a basic site with a host and as of recent the mysqli_fetch_all command has appeared to have stopped working as I receive the message:
Fatal error: Call to undefined function mysqli_fetch_all() in file at line where function is used
I rolled back the files on the server to a set that I know work and yet I run into the same issue even though the page is running PHP5.4+.
I cannot figure out why this has suddenly stopped working. Offline, using XAMPP, the mysqli_fetch_all command works perfectly and therefore the issue doesn't seem to be with the DB or the code. I would prefer not to rewrite numerous pages with a while loop for an unknown reason.
Is this an issue with the server host? Any help would be most appreciated.
There are two ways the MySQLi extension may be compiled:
By linking it against MySQL's client library
By compiling against the MySQL Native Driver that is bundled with php (mysqlnd)
mysqli_fetch_all() is only available in the second case, see http://php.net/mysqli_fetch_all
I would recommend to avoid such mysqlnd-only functions for compatibility reasons. If compatibility is not an issue for you and you desperately need this function, you have to recompile php --with-mysqli=mysqlnd.