Tag: PHP

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 list MySQL/MariaDB users and their privileges (using RDBMS client and PHP)

This note explains which queries can be used to list MySQL and MariaDB users. The article shows how to run these commands in MySQL/MariaDB query string as well as with PHP. How to display a list of users and their privileges using the DBMS client Queries to list MySQL / MariaDB users To list all users in MySQL / MariaDB,...

Finding multiline matches with PHP regular expressions

Multiline in PHP regular expressions By default, regular expressions in PHP look for matches within the same string. And in this case, the symbol “.” (dot) which is usually described as “anything” actually means “anything but a new line”. This default behavior can be overridden with a pattern modifier in case you need to find matches that extend beyond a...

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:...

phpMyAdmin error “Error: Undefined constant “SODIUM_CRYPTO_SECRETBOX_KEYBYTES”” (SOLVED)

On Arch Linux, when trying to use the phpMyAdmin 5.3 pre-release, I encountered an error: Error: Undefined constant "SODIUM_CRYPTO_SECRETBOX_KEYBYTES" Checking in Debian showed that there is no such problem with phpMyAdmin 5.3. The reason for the error is that sodium support is not enabled. How to enable sodium on Arch Linux (Manjaro, BlackArch) To enable sodium support in Arch Linux...

How to convert a string to lowercase in Bash

This note will show you how to convert a string to lowercase (small letters) on the Linux command line. To convert a string to lower case regardless of its current case, use one of the following commands. tr echo "Hi all" | tr '[:upper:]' '[:lower:]' hi all Attention! If you want to change the case of any letters other than...

How to convert a string to uppercase in Bash

This note will show you how to convert a string to upper case (capital letters, uppercase) on the Linux command line. To convert a string to capital letters regardless of its current case, use one of the following commands. tr echo "Hi all" | tr '[:lower:]' '[:upper:]' HI ALL Attention! If you want to change the case of any letters...
Loading...
X