December 3, 2022 in Php, Ubuntu
remove php 8.1 ubuntu
sudo apt-get purge php8.*
sudo apt-get autoclean
sudo apt-get autoremove
sudo systemctl restart apache2
December 3, 2022 in Php, Ubuntu
sudo apt-get purge php8.*
sudo apt-get autoclean
sudo apt-get autoremove
sudo systemctl restart apache2
December 3, 2022 in Php, Tips and Tricks, Ubuntu
If you are using ubuntu you can take update
$ sudo apt-get update
And install extension in case of php 5.6
$ sudo apt-get install php5.6-intl
And in case of php 7.0
$ sudo apt-get install php7.0-intl
And in case of php 8.1
$ sudo apt-get install php8.1-intl
And restart your apache after
$ sudo service apache2 restart
And restart your nginx after
$ sudo systemctl restart nginx
If you are using xampp then remove semicolon ( ; ) in xampp/php/php.ini from below line
;extension=php_intl.dll
December 3, 2022 in Php, Tips and Tricks, Ubuntu
The optional module, imagick, is not installed, or has been disabled.
$ sudo apt update
$ sudo apt install php php-common gcc
$ sudo apt install imagemagick
$ sudo apt install php7.4-imagick //install for specific php version
$ sudo apt install php-imagick //always install for latest php version
$ sudo systemctl restart apache2
October 11, 2022 in Php, Tips and Tricks
My htaccess file configuration
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
# Images
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/webp "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType image/x-icon "access plus 1 year"
# Video
ExpiresByType video/mp4 "access plus 1 year"
ExpiresByType video/mpeg "access plus 1 year"
# CSS, JavaScript
ExpiresByType text/css "access plus 1 month"
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
# Others
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^satta http://satta-king.soatechnology.net/
# Force SSL
#RewriteCond %{HTTPS} !=on
#RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Remove public folder form URL
# RewriteRule ^(.*)$ exxamm/exxamm/public/$1 [L]
</IfModule>
#Options +SymLinksIfOwnerMatch
#Options +FollowSymLinks
ErrorDocument 400 http://www.soatechnology.net/
ErrorDocument 401 /
ErrorDocument 403 http://www.soatechnology.net/
ErrorDocument 404 http://www.soatechnology.net/
ErrorDocument 301 http://www.soatechnology.net/
ErrorDocument 503 http://delhijurix.com/
<IfModule mod_rewrite.c>
# RewriteEngine On
#RewriteCond %{HTTPS} =on
#RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]
#RewriteEngine On
#RewriteBase /
#RewriteCond %{HTTPS} on
#RewriteRule ^ http://soatechnology.net/$1 [R=301,L]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"
ExpiresByType image/x-icon "access plus 1 year"
ExpiresDefault "access plus 2 days"
</IfModule>
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTPS} !on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RedirectMatch "^/wp-login/?" /login
</IfModule>
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# BEGIN FRedirect_ErrorDocument
# The directives (lines) between `BEGIN FRedirect_ErrorDocument` and `END FRedirect_ErrorDocument` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
#ErrorDocument 404 /index.php?error=404
# END FRedirect_ErrorDocument
Change value to only mod_rewrite section
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L,QSA]
</IfModule>
October 11, 2022 in Php
When you receive this error after fetching data from the database then it means that the database didn’t found any matching rows. Most database fetching functions return either null or an empty array when there are no matching records or when the result set has been exhausted.
To solve the problem you need to check for the truthiness of the value or for the existence of the key that you want to access.
$monday_lectures = "SELECT * from lectures where lecture_time = '11am to 1pm' and lecture_day = 'firday'";
$result_11to1 = mysqli_query($con, $monday_lectures);
$m11to1 = mysqli_fetch_array($result_11to1);
if ($m11to1 && $m11to1["lecture_day"] == !'') {
echo "<td>".$m11to1["lecture_name"]."</td>";
} else {
echo "<td> no class</td>";
}
$monday_lectures = "SELECT * from lectures where lecture_time = '11am to 1pm' and lecture_day = 'firday'";
$result_11to1 = mysqli_query($con, $monday_lectures);
$m11to1 = mysqli_fetch_array($result_11to1);
$lecture = $m11to1["lecture_day"] ?? null;
October 8, 2022 in Php
The problem is your query returned false meaning there was an error in your query. After your query you could do the following:
if (!$result) {
die(mysqli_error($link));
}
October 6, 2022 in Php, Ubuntu
The command will Uninstall Any of the PHP 8.X versions of PHP installed on your Server. Now we need to cleans obsolete deb-packages to do so we need to run autoclean command.
sudo apt-get purge php8.*
Now we need to cleans obsolete deb-packages to do so we need to run autoclean command.
sudo apt-get autoclean
remove orphaned packages that are no longer needed from the system so run autoremove command just like this.
sudo apt-get autoremove
September 22, 2022 in Laravel, Php
PHP get actual maximum upload size
echo ini_get("upload_max_filesize");
(int)ini_get("upload_max_filesize")*1024 will convert it to kbs
September 22, 2022 in Laravel, Php
$request->validate([
'amount' => 'required|numeric|max:9999999999',
'date' => 'required',
'description' => 'required|max:200',
]);
September 7, 2022 in Php
Type command
$ sudo php -i | grep 'Configuration File'
sudo service apache2 restart