Tag: Web Server

PHP Fatal error: Uncaught mysqli_sql_exception: No database selected (SOLVED)

Let's look at a small PHP code that tries to connect to a MySQL or MariaDB DBMS and execute a query with a “SELECT” statement: <?php $db_user = "root"; $db_password = ""; $mysqli = new mysqli("localhost", $db_user, $db_password); if ($mysqli->connect_errno) { printf("Somehow we failed: %s\n", $mysqli->connect_error); exit(); } $query = "SELECT * FROM TestTABLE;"; $result = $mysqli->query($query); while ($row =...

“ERROR 1366 (22007): Incorrect string value” in MySQL/MariaDB (SOLVED)

How to insert emoji into MySQL/MariaDB database On the one hand, inserting emoji into a MySQL / MariaDB database table does not require any special preparatory steps – just insert one or more emoji characters, which may contain other text. For example: INSERT INTO TestTABLE (`test_column`) VALUES ("🎫⏭️✈️ and hi 🌅"); But when executing the previous request, you may encounter...

PHP not displaying emoji from MySQL/MariaDB database (SOLVED)

When retrieving rows from a MySQL (MariaDB) database, you may encounter a situation where all the text is displayed correctly, but question marks are displayed instead of emoji. The most likely problem is an incorrectly used encoding when executing queries against the MySQL (MariaDB) DBMS. There are two ways to fix this situation. 1. Select utf8mb4_unicode_ci encoding when creating database...

How to get data from a web page using GET and POST methods in a Python script on Windows

Python programs and scripts can make requests to and receive data from websites and web services using the GET and POST methods (as well as other HTTP methods: PUT, PATCH and DELETE). But what if you want to pass data from a web page to a Python script? This can be done in several ways. How to get data from...

How to get data from a web page using GET and POST methods in a Python script

Python programs and scripts can make requests to and receive data from websites and web services using the GET and POST methods (as well as other HTTP methods: PUT, PATCH and DELETE). But what if you want to pass data from a web page to a Python script? This can be done in several ways. How to get data from...

How to install Python as a CGI module in Apache on Linux

Table of contents 1. How to run a Python script on a web server 2. How to set up Python as a CGI module in Apache on Debian (Ubuntu, Linux Mint, Kali Linux) 2.1 Setting up Python CGI for a single directory 2.2 Setting up Python CGI for the entire web server 3. How to set up Python as a...

How to set up Python as a CGI module in Apache on Arch Linux (Manjaro, BlackArch)

Setting up Python CGI for a single directory Create a directory /srv/http/cgi-bin/ - this is where the Python scripts will be located: sudo mkdir /srv/http/cgi-bin/ Open the /etc/httpd/conf/httpd.conf file – the web server configuration file: sudo gedit /etc/httpd/conf/httpd.conf Find a group of lines: <Directory "/srv/http/cgi-bin"> AllowOverride None Options None Require all granted </Directory> And replace it with: <Directory "/srv/http/cgi-bin"> AllowOverride...

How to set up Python as a CGI module in Apache on Debian (Ubuntu, Linux Mint)

Setting up Python CGI for a single directory Run the command to enable the CGI module: sudo a2enmod cgi Restart the web server for the changes to take effect: sudo systemctl restart apache2 Create file /usr/lib/cgi-bin/test.py: sudo gedit /usr/lib/cgi-bin/test.py Copy the following content to this file: #!/usr/bin/python3 print ("Content-type: text/html") print ("") print ("") print ("<html><head>") print ("") print ("</head><body>")...

PHP Warning: PHP Startup: imap: Unable to initialize module (SOLVED). How to install the imap module for PHP on Arch Linux

When running a PHP script in Arch Linux or derivative distributions (Manjaro, BlackArch) on the command line: php 8.php You may see the following warning from PHP: PHP Warning: PHP Startup: imap: Unable to initialize module Module compiled with module API=20210902 PHP compiled with module API=20220829 These options need to match in Unknown on line 0 Warning: PHP Startup: imap:...

Error “No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed” (SOLVED)

Debian and derivative distributions (Ubuntu, Linux Mint, Kali Linux, and many others) may experience a “FCGI: attempt to connect to Unix domain socket /run/php/php8.1-fpm.sock (*:80) failed” error when migrating from PHP 8.1 to PHP 8.2. Apache web server log sudo tail /var/log/apache2/error.log contains the following error messages: [Sun Jan 29 03:05:45.213609 2023] [proxy:error] [pid 1313500] (2)No such file or directory:...
Loading...
X