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.
Related
I have this shared account on Hostgator. Using PHP 7.1 and mysqli_connect, I have no issue connecting to the MySQL 5.3.36 database. The PHP script should be fine. The hosting company sent me an email to let me know they will support PHP 7.4 and they will remove all older versions in a month. I then switched the account to PHP 7.4. The Wordpress blog needed some tuning, but it is now working with PHP 7.4. The other database I use for a dynamic file catalogue won't connect using PHP 7.4. I am getting the following error message:
The server requested authentication method unknown to the client
According to my searches, it seems the culprit is the MySQL authentication plugin and MySQL won't handle password properly for that reason. I would try to fix that, but it looks that I can't change the plugin (mysql_native_password) from my account and the host company tech support could care less about my issue. Their best answer was to downgrade PHP to 7.1. It is a quick fix, but it won't work after they remove it in a month. I could also move the site elsewhere or use a remote database, but does anyone know an actual way to fix that bug and have everything there working?
After using mysql in terminal, I reviewed my user passwords and I got a "password needs to be 41 character hash" error message. I simply changed my passwords and it is now working. It seems that something has changed in how passwords are stored or the bug was fixed. Thanks.
I am changing my hosting provider and migrating from cPanel to Plesk. Everything is nice and I am exited but I can't get old PHP scripts working which still use MySQL instead of MySQLi or PDO.
Plesk lets different accounts or domains use different versions of PHP. Fortunately even older versions that still recognize MySQL are available (5.4, 5.5, 5.6) and I have actually managed to make one of my domains to use PHP 5.6 but although it works there, MySQL is still not available. MySQLi is working with PHP 5.6 but all point of downgrading PHP was to get MySQL working. It simply complains: 'Call to undefined function mysql_connect()'.
As far as I can see mysql extension is installed. phpinfo() shows sections of mysql and mysqli and mysqlnd and even pdo_mysql. mysql.so is there at /opt/plesk/php/5.6/lib64/php/modules.
I have tried all the options in Plesk and I have edited the ini files (extension=mysql.so) but no progress. I have spent all day already. Have also tried different handlers.
One thing that I have noticed is on the phpinfo() page. 'Configure Command' section contains among the other strings, the following: '--without-mysql'. I don't see a way in Plesk to remove this. And I don't see a way to change configure options for PHP. Is this the reason why mysql_ functions don't work? How to solve this? I got it working easily with cPanel but Plesk is new to me and Google has not been helpful today. Please advice!
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:
Or is php 5.4 only compatible with mysql? I've been having some problems getting my php to work with mysql.
I'm using PHP 5.6.6, Apache 2.4, MySQL 5.6.23. My PHP and Apache work just fine. I created a website using CSV. I wanted to learn how to use MySQL, but I was having problems trying to get MySQL to work with my PHP. Now, I have never take any courses on MySQL nor have I ever used. The only thing I have done with MySQL is install it from the community tab from the MYSQL download page. I followed all the instruction and set my file path to be C:\mysql, and my data path to be C:\mysqldata, but I don't know, why it doesn't seem to work with my php when I try to connect. Is there another step I have to take to connect? I know a lot of people use WAMP, which is something I might look into if I don't get this working, but If there's anyone who has installed all three (apache php and mysql) sperately, know what my problem might be, I'll really appreciate it.
PDO works on all PHP versions 5.1+, which is the preferred method to connect to MySQL.
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. ^^