My code is like this:
if( ($this->master=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0 )
{
die("socket_create() failed, reason: ".socket_strerror($this->master));
}
when I run my php file which create connection with web socket, I got error
Fatal error: Call to undefined function socket_create() in the line
if( ($this->master=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0 )
Therefore i am not able to connect web socket and also not able to get response message from socket because Socket Status: 3 (Closed) is displaying in my browser when run client page .
Have you got an idea what is missing?
Thank you in advance.
You'll need to install (or enable) the Socket PHP extension: http://www.php.net/manual/en/sockets.installation.php
For a typical XAMPP install on windows you probably have the php_sockets.dll in your C:\xampp\php\ext directory. All you got to do is go to php.ini in the C:\xampp\php directory and change the ;extension=php_sockets.dll to extension=php_sockets.dll.
If you are using xampp 7.3.9. socket already installed. You can check xampp\php\ext and you will get the php_socket.dll. if you get it go to your xampp control panel open php.ini file and remove (;) from extension=sockets.
Open the php.ini file in your server environment and remove ; from ;extension=sockets. if it's doesn't work, you have to download the socket extension for PHP and put it into ext directory in the php installation path. Restart your http server and everything should work.
Follow these steps if you're on openSuse or SUSE.
Install php7 if it's not already installed.
zypper in php7
If you have php7 installed, update it with:
zypper update php7
Install php7-sockets
zypper in php7-sockets
Sometimes the version of your xampp (wamp or ...) is different with CLI. I suggest first using php --ini to find that use a correct version.
Moreover to solve this problem, you can open your xampp and use shell.
I got this error when my .env file was not set up properly. Make sure you have a .env file with valid database login credentials.
Related
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
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
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
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
My code is like this:
if( ($this->master=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0 )
{
die("socket_create() failed, reason: ".socket_strerror($this->master));
}
when I run my php file which create connection with web socket, I got error
Fatal error: Call to undefined function socket_create() in the line
if( ($this->master=socket_create(AF_INET,SOCK_STREAM,SOL_TCP)) < 0 )
Therefore i am not able to connect web socket and also not able to get response message from socket because Socket Status: 3 (Closed) is displaying in my browser when run client page .
Have you got an idea what is missing?
Thank you in advance.
You'll need to install (or enable) the Socket PHP extension: http://www.php.net/manual/en/sockets.installation.php
For a typical XAMPP install on windows you probably have the php_sockets.dll in your C:\xampp\php\ext directory. All you got to do is go to php.ini in the C:\xampp\php directory and change the ;extension=php_sockets.dll to extension=php_sockets.dll.
If you are using xampp 7.3.9. socket already installed. You can check xampp\php\ext and you will get the php_socket.dll. if you get it go to your xampp control panel open php.ini file and remove (;) from extension=sockets.
Open the php.ini file in your server environment and remove ; from ;extension=sockets. if it's doesn't work, you have to download the socket extension for PHP and put it into ext directory in the php installation path. Restart your http server and everything should work.
Follow these steps if you're on openSuse or SUSE.
Install php7 if it's not already installed.
zypper in php7
If you have php7 installed, update it with:
zypper update php7
Install php7-sockets
zypper in php7-sockets
Sometimes the version of your xampp (wamp or ...) is different with CLI. I suggest first using php --ini to find that use a correct version.
Moreover to solve this problem, you can open your xampp and use shell.
I got this error when my .env file was not set up properly. Make sure you have a .env file with valid database login credentials.