Not connecting PHP file to RDS MySQL database [duplicate] - php

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?

Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent

On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.

For CentOS, do:
sudo yum install php-mysqli

On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql

Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.

If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"

Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli

On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart

If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"

if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli

There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.

Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();

So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.

I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

Related

PHP 8.2: mysqli_connect is not any longer a function? What's it's new replacement? [duplicate]

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent
On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.
For CentOS, do:
sudo yum install php-mysqli
On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql
Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.
If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"
Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli
On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart
If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"
if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli
There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.
Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();
So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.
I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

Setup the Application information, Database connection and SMTP server [duplicate]

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent
On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.
For CentOS, do:
sudo yum install php-mysqli
On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql
Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.
If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"
Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli
On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart
If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"
if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli
There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.
Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();
So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.
I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

MYSQLi-Connection does't work when PHP-Code is included in HTML [duplicate]

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent
On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.
For CentOS, do:
sudo yum install php-mysqli
On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql
Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.
If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"
Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli
On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart
If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"
if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli
There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.
Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();
So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.
I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

mysqli_connect() function error when trying to run the php file [duplicate]

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent
On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.
For CentOS, do:
sudo yum install php-mysqli
On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql
Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.
If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"
Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli
On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart
If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"
if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli
There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.
Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();
So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.
I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

Codeigniter mysqli Issue [duplicate]

For 2 days now I'm trying to solve this, but unfortunately no result. Let me tell you my story about the problem. I've bulid an application on a site, and the application deals with the reviews. But, I'm trying to put it on another site, and I copyed the php files, the sql file from the old site, and moved them to the new site (they are on different FTP servers). When I'm trying to go to the pages from the application, I receive this FATAL ERROR:
Fatal error: Call to undefined function mysqli_connect()
The code that I wrote to connect to the database is this (with hidden credentials):
$con = mysqli_connect("","*the_name*","*the_pass*","*the_database*");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
Why do I get the error? It works on the old server, and the code I think it's not the problem, because it works on localhost, and on the new server it doesn't. Can anyone help me?
Simply do it
sudo apt install php-mysqli
It works perfectly and it is version independent
On Windows, the extension extension=php_mysqli.dll can be enabled by removing the semicolon ';' at the beginning of the extension name from the php.ini file.
For CentOS, do:
sudo yum install php-mysqli
On Ubuntu I had to install php5 mysql extension:
apt-get install php5-mysql
Happens when php extensions are not being used by default. In your php.ini file, change ;extension=php_mysql.dll to extension=php_mysql.dll. **If this error logs, then add path to this dll file, eg extension=C:\Php\php-???-nts-Win32-VC11-x86\ext\php_mysql.dllDo same for php_mysqli.dll and php_pdo_mysql.dll. Save and run your code again.
If you have the module installed and set your PHP.INI file properly, check your apache error log for something like the following:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\\php\\ext\\php_mysqli.dll' - The specified module could not be found.
In this case, your extension directory is not what you think it is. You may neeed to set it explicitly, like so:
extension_dir="C:\xampp\php\ext"
Mine was a bit different for php7 on centos7.
In /etc/php.ini
; extension=mysqli
to
extension=mysqli
On Raspberry Pi I had to install php5 mysql extension.
apt-get install php5-mysql
After installing the client, the webserver should be restarted. In case you're using apache, the following should work:
sudo service apache2 restart
If you host the server yourself, and that server happens to be Apache, you can also get this error even if you have uncommented extension=php_mysqli.dll in php.ini.
You also need to tell Apache where to find php.ini by using the PHPIniDir directive in Apache's httpd.conf
AddHandler application/x-httpd-php .php
PHPIniDir "<path-to-folder-where-php-ini-lives>"
if you use ubuntu 16.04 (maybe and above),you have this module already but not enabled by default. Just do this:
sudo phpenmod mysqli
There is no error in the, but the mysqli PHP extension is not installed on your machine. Please contact your service provider to fix this issue.
Mysqli isn't installed on the new server. Run phpinfo() to confirm.
<?php
phpinfo();
So this may not be the issue for you, but I was struggling with this error. I discovered what was causing my problem, though I can't really explain as to why.
For me, mysqli_connect was working fine where the connection was made on pages in any various sub-directory. For some reason though, the same code referenced on pages in the root directory was returning this error. The strange thing is that it was working fine on my localhost environment in MAMP in the root directory, however on my shared host it was not.
After struggling to figure out what was giving me "Error 500" white screen from this "PHP Fatal Error," I went through the code and stumbled upon this code in the error handling that was suggested by the PHP Manual (https://www.php.net/manual/en/mysqli.error.php).
if (!mysqli_query($link, "SET a=1")) {
printf("Error message: %s\n", mysqli_error($link));
}
I randomly decided to remove it and, voila, connection to the database working in root directories. Maybe someone smarter than me can explain this, for anyone struggling with a similar issue.
I followed below link to fix this problem. Make sure to enable following Module.
php -r 'phpinfo();' | grep -i mysqli
Link : https://askubuntu.com/questions/773601/php-mysqli-extension-in-ubuntu-16-04-not-working-after-upgrade-to-version-7-0-6

Categories