Fatal error: Uncaught Error: Call to undefined function ImageCreate() in C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php:74 Stack trace: #0 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php(32): QRimage::image(Array, 5, 4) #1 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrencode.php(494): QRimage::png(Array, 'temp/184011_inf...', 5, 4, false) #2 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrencode.php(286): QRencode->encodePNG('\tRoll no: 18401...', 'temp/184011_inf...', false) #3 C:\xampp\htdocs\the_base\qr\index.php(57): QRcode::png('\tRoll no: 18401...', 'temp/184011_inf...', 0, 5) #4 {main} thrown in C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php on line 74
This is the error I am getting since I've updated my XAMPP. This same code has worked perfectly with an older version of xampp but when I updated it, the code suddenly started to give this error
I am trying to create a QR code in png format and make it downloadable
I did a little research about it, it said that the GD lib was missing in the PHP but all the steps shown to fix it were of LINUX OS, I am currently using Windows.
go to php.ini file xampp/php/php.ini
search for ;extension=gd and ;extension=gd2
remove the ; from both lines, then restart the server
there might be two cases:
1.gd installed and disabled
2. gd not installed and disabled
for first case:
on XAMPP server click on Apache config -> php.ini
1.open this file in notepad
2. search for ;extension=gd or ;extension=gd2
3. remove the colon ; ( just extension=gd)
4. save it .
for second case gd not installed:
check it through:
(on browser) localhost/dashboard
xampp dashboard opens up, on upper left go to phpinfo()
search for gd section if not present then follow down:
1.open folder : xampp/php/ext
2. then find and Copy php_gd.dll and paste it into the following folder
3.C:\Windows\System32
4. paste php_gd.dll here.
5. restart xampp server and run.
for better explanation:
https://www.geeksforgeeks.org/how-to-install-php-gd-in-windows/
It seems like the php_gd2 extension isn't enabled.
you have to enable it in php.ini. To do this, simply open php.ini and uncomment (remove the leading ;) the following line:
extension=php_gd2.dll
Related
I have a simple test code:
<?php
var_dump(curl_init());
echo '.';
if I run it on command line (Windows 10) I get the expected result:
php.exe test.php
resource(4) of type (curl) .
very fine. But when Im running this file from browser (set to Apache rootdir).
Fatal error: Uncaught Error: Call to undefined function curl_init() in
Im speachless. For legacy reasons, this is php 7.04 (on 7.2, 7.4, 8.1 everything is fine).
The php.ini does work. Of course "extension=php_curl.dll" is enabled. When I change something, for example "max_execution_time = 300", the php_info(); also reinforcements me that these settings are taken into account.
However, the strange thing is what php_info() is saying:
cURL Sterling Hughes
nothing more for curl!
EDIT:
I tried the same with "extension=php_gd2.dll" and it does work if I remove/readd it, phpinfo shows that correctly!
This is because the php folder is not in your system PATH (not user), Apache doesn't know where to search dlls. The easiest way is adding php folder to PATH.
If you doesn't want to do that, you probably need set extension_dir to the full path of your extension folder in php.ini. for example:
extension_dir = "D:\Program Files\php-7.04-ts\ext"
cURL extension needs openssl to work. and you can also find these dlls in php folder, just copy them to Windows or system32 folder. According to RiggsFolly's comment you can copy these required dlls to Apache\bin folder.
libssl-1_1-x64.dll / libeay32.dll
libcrypto-1_1-x64.dll / ssleay32.dll
libssh2.dll
I'm trying and failing to use tesseract php. I get this error:
Fatal error: Uncaught thiagoalessio\TesseractOCR\TesseractNotFoundException: Error! The command "tesseract" was not found. Make sure you have Tesseract OCR installed on your system: https://github.com/tesseract-ocr/tesseract
The current $PATH is C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\xampp\php;C:\ProgramData\ComposerSetup\bin;C:\Users\Peppe\AppData\Local\Microsoft\WindowsApps;C:\Users\Peppe\AppData\Roaming\Composer\vendor\bin in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php:48 Stack trace: #0
C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\TesseractOCR.php(26): thiagoalessio\TesseractOCR\FriendlyErrors::checkTesseractPresence('tesseract') #1 C:\xampp\htdocs\index.php(7): thiagoalessio\TesseractOCR\TesseractOCR->run() #2 {main} thrown in C:\Users\Peppe\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 48
I'm using windows 10 with xampp installed in C:\xampp. php version 7.4
I installed tesseract.exe from https://github.com/UB-Mannheim/tesseract/wiki both x32 and x64
I used composer to install the https://github.com/thiagoalessio/tesseract-ocr-for-php and it gave no error.
<?php
require_once 'C:\Users\Peppe\vendor\autoload.php';
use thiagoalessio\TesseractOCR\TesseractOCR;
$ocr = new TesseractOCR("caption.jpg");
$content = $ocr->run();
echo $content;
?>
finally, the caption.jpg is in the htdocs folder, the main folder and same folder as index.php where the aforementioned code appears.
any solutions?
I found the answer:
the $PATH variable is taken from Windows. To set it right search for "system environment variables", click "environment variables", edit PATH and add the tesseract software folder, for example C:\Program Files\Tesseract-OCR
In my case I have to add new variable tesseract with full path C:\Program Files\Tesseract-OCR\tesseract.exe as showing in below screenshot
To install TESSERACT OCR and use it in PHP
You must perform the following steps:
(in my explanation, I assume you are on windows)
url src = https://tesseract-ocr.github.io/tessdoc/Installation.html
1- Download the TESSERACT software from URL:
https://github.com/UB-Mannheim/tesseract/wiki
2- From your composer, you must install:
url: https://packagist.org/packages/thiagoalessio/tesseract_ocr
composer require thiagoalessio/tesseract_ocr
3- Then, it is important to do things in the following order:
Your TESSERACT software (step 1) is installed in a directory
which will certainly be (it's up to you to check in your system)
folder = C:\Program Files\Tesseract-OCR
It is absolutely necessary to add this folder in the windows environment variables at the PATH level (user and system)
4- Then you restart your web environment (WAMP, LARAGON ...)
5- Verification that TESSERACT is operational.
Go to your CMD and write:
tesseract --version
Reply somethink like that :
tesseract v5.3.0.20221222
leptonica-1.78.0
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.3) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found FMA
Found SSE4.1
Found libarchive 3.5.0 zlib/1.2.11 liblzma/5.2.3 bz2lib/1.0.6 liblz4/1.7.5 libzstd/1.4.5
Found libcurl/7.77.0-DEV Schannel zlib/1.2.11 zstd/1.4.5 libidn2/2.0.4 nghttp2/1.31.0
6- Operation test from a PHP script
uses an image on a white background with text
<?php
$app_class = 'thiagoalessio\TesseractOCR\TesseractOCR';
$file = 'C:/Users/admin/Desktop/im2.jpg';
$class = new ReflectionClass($app_class);
$infoImg = $class->newInstanceArgs();
$infoImg->lang('eng','jpn','spa','fr');
$infoImg->image($file);
$infoImg->withoutTempFiles();
$resultat = $infoImg->run();
var_dump($resultat);
?>
Uncaught Error: Call to undefined function CodeIgniter\locale_set_default()
in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
Stack trace:
#0 C:\xampp\htdocs\sunpay-ci4\system\bootstrap.php(181): CodeIgniter\CodeIgniter->initialize()
#1 C:\xampp\htdocs\sunpay-ci4\public\index.php(36): require('C:\\xampp\\htdocs...')
#2 {main} thrown in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php on line 184
I don't understand this error, the first page works if I drop this package.
Try opening php.ini from the control panel:
Apache row -> Config -> php.ini
Then enable intl extension by removing ; in front of extension=intl
Edit: the reason it fails is because the intl extension is disabled by default in xampp
Recently I stuck on the same problem on CI version 4.0.4.
Follow the steps to fix it.
Click on "config" from the xampp control panel.
Then click on php.ini option.
Then it will open on your default text editor application (for me it is Notepad). then click on find option.
Then search for ";extension=intl".
replace ";extension=intl" with "extension=intl".
That's all. Thanks.
get your php version by put this code : phpinfo();die(); in your index.php after <?php so it looks like like <?php phpinfo();die();
PHP Version 7.2.24-0ubuntu0.18.04.7
jump to /etc/php/{your php version}/apache2 folder; example : /etc/php/7.2/apache2 and open php.ini then find ;extension=intl and remove the semicolon ;
open your terminal then write or copy paste this command sudo systemctl restart apache2 and press ENTER
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
==============================================================================
if you still get the same error please try to install intl extension using this command in your terminal:
sudo apt install php{your php version}-intl
sudo systemctl restart apache2`
example :
sudo apt install php7.2-intl
sudo systemctl restart apache2
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
=============================================================================
#NB :
dont forget to remove phpinfo();die(); in the first step
sorry for my bad english
Just go to the mentioned line in display in error.
C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
You can find it here: root folder/system/CodeIgniter.php
on line no 184 you will find the below code.
locale_set_default($this->config->defaultLocale ?? 'en');
just comment it like this.
#locale_set_default($this->config->defaultLocale ?? 'en');
Now, the code is working.
1.search for intl and uncomment this extension in php.ini file by removing ; from begin of line extension=intl
2. restart Apache service by stop and starting it again from xampp control panel
When i started a new project i got this error on welcome screen. Fatal error: Uncaught Error: //pp\Views\welcome_message.php:222 Stack trace: #0 {main} thrown in. It appears like there is a problem with the installation of codeigniter but in fact it is an echo error in line 222 of the welcom_message.php page go there an remove the <?= CodeIgniter\CodeIgniter::CI_VERSION ?> from line 222 it should look like this
<div class="heroe">
<h1>Welcome to CodeIgniter </h1>
<h2>The small framework with powerful features</h2>
</div>
Then it will echo hello screen correctly
Usually to get round this try these three points:
Ensure .writable folder is writable with file permissions 0777 (must have leading zero)
Try setting the following in index.php -> $_SERVER['CI_ENVIRONMENT'] = 'development'; and toggle with $_SERVER['CI_ENVIRONMENT'] = 'production' in .env file;
Access this file(CodeIgniter.php) in the following directory: project_folder/vendor/codeigniter4/framework/system/CodeIgniter.php
public function initialize()
{
if( function_exists('locale_set_default' )):
locale_set_default($this->config->defaultLocale ?? 'en');
endif;}
if your have installed Apache, PHP, MYSQL manually, then set locale to app in .env file:
app.locale = "en"
save and restart apache service
When i try using the GD Library in PHP 7.4.6 on my Windows PC, it shows me this error:
Fatal error: Uncaught Error: Call to undefined function imagecreate() in C:\Users\user\Desktop\Site\index.php:11 Stack trace: #0 {main} thrown in C:\Users\user\Desktop\Site\index.php on line 11
The line 11 is:
$image = imagecreate(200,20);
The full PHP code is:
<?php
$image = imagecreate(200,20);
$background = imagecolorallocate($image,0,0,0);
$foreground = imagecolorallocate($image, 255,255,255);
$imagestring($image,5,5,1,"Test",$foreground);
$header("Content-type: image/jpeg");
$imagejpeg($image);
?>
I tried fixing this by following this guide, and i uncommented the GD line, but it still gives me this error.
Thanks in advance.
Do a php -m to see PHP modules. If you can't find gd there then you need to install and enable that extension. There a lot of tutorials in internet to doing so
I had the same problem with apache and GD.
See https://stackoverflow.com/a/72565820/9630486
The problem was in php.ini path for apache. By default it is not using php.ini from php directory. You need to define PHPIniDir in httpd file or place copy of php.ini to apache folder.
Go to php.ini file search this
;extension=gd
Remove ; then restart the server
Try this code:
<?php
phpinfo();
Search for "GD Support" in the resulting output. If you don't see it or it's not enabled, you need to enable gd in php.ini - search for:
;extension=php_gd2.dll
Remove the comment in front of it, save the ini file, and restart IIS/Apache/Nginx/whatever server you're running.
I am using Windows 7, php 5.3.5 and WAMP server. I have two php files: trigger.php and background.php.
I want to run background.php as a background process. I have to call this file from trigger.php. To accomplish this I used below method.
I included following code in trigger.php to make background.php to process in background.
$handle = popen('start /b C:\wamp\bin\php\php5.3.5\php.exe C:\wamp\www\email3.php','r');
in background.php I have the follwing code to connect to database.
$conn_string = "host=localhost port=5432 dbname=tagbase user=postgres password=postgres";
now, on parsing this line am getting the follwing error :
Fatal error: Call to undefined function pg_connect() in C:\wamp\www\background.php on line 3 Call Stack: 0.0002 322792 1. {main}() C:\wamp\www\background.php:0
By searching in in the internet I found some solutions, and made changes as recommended below in php.ini,
uncommented, extension=php_pdo_pgsql.dll,
uncommented, extension=php_pgsql.dll,
uncommented, extension_dir = "c:/wamp/bin/php/php5.3.5/ext/",
also I do have php_pdo_pgsql.dll and php_pgsql.dll files in c:/wamp/bin/php/php5.3.5/ext/ folder.
Any suggestions are appreciated.
Apache 2.2.X configuration
Add the next line to the Apache 2.2.x httpd.conf configuration:
LoadFile "C:/Program Files/PostgreSQL/{version}/bin/libpq.dll"
Above line must be entered before the next line.
LoadModule php5_module "c:/wamp/bin/php/php5.2.11/php5apache2_2.dll"
PHP 5.2.X Configuration
Enable the following two lines in the php.ini configuration file. By 'Enable' i mean, remove trailing ; (semicolon). By these, you un-comment the line.
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
Restart WAMP
Test by adding this in your index.php
echo extension_loaded('pgsql') ? 'yes':'no';
(source: http://www.plaatsoft.nl/wamp-postgresql-integration/)
if we install WAMP server, we will get two php.ini files.
one in C:\wamp\bin\php\php5.3.5 and another in C:\wamp\bin\apache\Apache2.2.17\bin.
if we execute a php file from browser, then php.ini file in C:\wamp\bin\apache\Apache2.2.17\bin will be referred.
if we execute a php file from command line, then php.ini file in C:\wamp\bin\php\php5.3.5 will be referred.
what ever the changes i made enable/disable the dll in PHP->PHP extensions,all the changes will be saved in
C:\wamp\bin\apache\Apache2.2.17\bin\php.ini file. but C:\wamp\bin\php\php5.3.5\php.ini file remains unchanged.
for my problem, i made the following changes
uncommented, extension=php_pdo_pgsql.dll,
uncommented, extension=php_pgsql.dll,
uncommented, extension_dir = "c:/wamp/bin/php/php5.3.5/ext/",
in C:\wamp\bin\php\php5.3.5\php.ini file. Now its working good. :)
In my case with
Apache/2.4.10
PHP Version 5.4.32
PostgeSQL 9.3
I added libpq.dll into Apache httpd.conf from PHP catalog because Apache refused to start with libpq.dll from PostgreSQL 9.3