I'm not sure why I'm still getting the PHP is not recognized as an internal or external command error. Here's my environment variables:
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\EgisTec MyWinLocker\x64;C:\Program Files (x86)\EgisTec MyWinLocker\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin; C:\PHP\;
My PHP.exe is located in "C:\PHP\", so I'm not sure why I'm getting this error. :/
I don't have a Windows machine to verify this, but I am pretty sure you cannot have spaces after the ; delimiters. Remove the space before C:\PHP, and it may be harmless, but also remove the trailing \.
C:\Program Files (x86)\NVIDIA Corporation\;...snip...;C:\strawberry\perl\bin;C:\PHP
-------------------------------------------------------------------------^^^^^
Depending on how you are launching PHP, you might need to log out of Windows and back in to propagate the new %PATH% through your environment, though I doubt that's necessary.
Try only: C:\PHP (Without the last '\'). After this save the changes, restart your computer and write this on your cmd
php -v
to verify.
Related
I spent two days setting up my PHP connection to SQL Server.
I downloaded the drivers, added them to the C:\Program Files\php\ext folder (as indicated by phpinfo()). Then I modified the php.ini file to add those extensions. Then I went to services and restarted "SQL Server EXPRESS". Nothing worked until I found that PHP is also installed in another folder on my PC: C:\Program Files\iis express\PHP\v8.0. So I added the drivers there too and changed the php.ini file and restarted the SQL Server EXPRESS service (is that what they mean with restarting your web server?). The phpinfo() page said:
Configuration File (php.ini) Path: no value
Loaded Configuration File: C:\Program Files\iis express\PHP\v8.0\php.ini
and there was no section "sqlsserver". I gave up and the next day it magically worked. The phpinfo had a "sqlserver" section and the connection to my database no longer said "Call to undefined function sqlsrv_connect()".
Now, I had to download Laravel for my course, and install Composer. When doing so, it was unable to install when I had C:\Program Files\iis express\PHP\ as my PATH and it asked me if I wanted to make C:\Program Files\php\ my PATH instead. So I clicked yes, and the installation was successful.
Laravel works, however now my database connections with SQL Server don't work anymore! I get the same old "Call to undefined function sqlsrv_connect()" error, and my phpinfo() now says
Configuration File (php.ini) Path:
Loaded Configuration File: C:\Program Files\php\php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
and there is no longer a "sqlsserver" section on the page.
I have tried everything in StackOverflow articles, such as removing the semicolon in the php.ini extension, including the full address in the extensions in the php.ini file, including the extensions of the other php folder into this php.ini file, restarting SQL Server service, etc. But nothing works. I also don't know how to reset the old PHP folder back into the PATH variable.
My connection code is:
$con = sqlsrv_connect( 'localhost' ,
[ 'Database' => 'sample_db' ,
'UID' => 'sample_user' ,
'PWD' => 'sample_password' ]
);
//Print error message if the database doesn't connect
if ($con === false ){
echo 'Failed to connect to db: ' . sqlsrv_errors()[ 0 ][ 'message' ];
exit ();
}
How can I have these two php folder on my computer both work, the one for my PHP SQL Server database connection, and the other for my Laravel programme to run? Has anyone else had this issue and I so, what worked for you?
I managed to resolve this by changing the PATH back to the php folder instead of the iis/php folder. I was worried that would break my Laravel now, but it didn't.
I find a problem to use tesseract_ocr in php, I follow this tutorial https://github.com/thiagoalessio/tesseract-ocr-for-php.
I install tesseract_ocr use composer :
$ composer require thiagoalessio/tesseract_ocr
this is my folder structure in localhost :
this is mycode :
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
require __DIR__ . "/vendor/autoload.php";
use thiagoalessio\TesseractOCR\TesseractOCR;
echo (new TesseractOCR('images/8055.PNG'))
->whitelist(range('A', 'Z'))
->run();
?>
</body>
</html>
this is my php version :
and in the browser 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:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_73\bin;C:\Users\frank\AppD in C:\xampp\htdocs\ocr\vendor\thiagoalessio\tesseract_ocr\src\FriendlyErrors.php on line 48
please anyone help me to solve this problem.
Thanks.
You need to install Tesseract OCR on your pc from here:
https://github.com/tesseract-ocr/tesseract
Then your code should be(just in case you are on windows, C:\Program Files\Tesseract-OCR\tesseract.exe is the path of Tesseract engine):
echo (new TesseractOCR($img_url))
->executable('C:\Program Files\Tesseract-OCR\tesseract.exe')
->whitelist(range('A', 'Z'))
->lang('eng')
->run();
Make sure the tesseract folder is in your path.
If you're unsure what I'm saying, click on the start button and type "edit the system environment variables". Click Environment Variables, under "System variables" click on the line that has "Path" on the far left, and click edit. Click "New" and put in the path to your executable, depending on if you're using the 64 bit or 32 bit version. In my case it was "C:\Program Files\Tesseract-OCR".
You can test this now by opening a new command prompt (if you had an old one open, it won't have the new path variable), and type tesseract and hit enter. You should see:
Usage:
tesseract --help | --help-extra | --version
tesseract --list-langs
tesseract imagename outputbase [options...] [configfile...]
OCR options:
-l LANG[+LANG] Specify language(s) used for OCR.
NOTE: These options must occur before any configfile.
Single options:
--help Show this help message.
--help-extra Show extra help for advanced users.
--version Show version information.
--list-langs List available languages for tesseract engine.
If you do, then it's installed and globally working on your machine now and should work with PHP. If you want to get it working without composer, look up my other answer about that on here.
I'm trying to get PHP SNMP to work on XAMPP PHP 7.1.9
I'm always getting this result: Warning: SNMP::get(): No response from 127.0.0.1
Here's what I did:
Enabled php_snmp.dll on php.ini
Installed net-snmp-5.5.0-2.x64
Added windows environment variable MIBDIRS with value C:\usr\share\snmp\mibs
Code I'm running to test:
<?php
$session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
$sysdescr = $session->get("sysDescr.0");
echo "$sysdescr\n";
$session->close();
I'm new to this so I'm not sure what I'm missing.
The problem was with the MIBDIRS path.
I followed php docs and it says:
The Windows distribution of Net-SNMP contains support files for SNMP in the mibs directory. This directory should added to Windows' environment variables, as MIBDIRS, with the value being the full path to the mibs directory: e.g. c:\usr\mibs.
Problem was I couldn't find c:\usr\mibs on my net-snmp installation so I used C:\usr\share\snmp\mibs instead.
Solution:
I tried using a device with snmp support instead of 127.0.0.1 and ran snmpget on cli and confirmed net-snmp installation actually works. I figured the problem must be with the path php is using to run snmp.
So I used where snmpget to check the command path then changed MIBDIRS environment value with the result which is C:\usr\bin\snmpget.exe
When I run php from the command line (on Windows), I receive the following message
Failed loading C:\Users\Nickey K\Documents\AMD APP\bin\x86_64;C:\Users\Nickey K\
Documents\AMD APP\bin\x86;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program F
iles (x86)\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Window
s Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Prog
ram Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C
:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program F
iles (x86)\Calibre2\;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files
(x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-
Static;C:\Program Files (x86)\EasyPHP-12.0\php\php544x120715104042;\php\php544x1
20715104042\php_xdebug-2.2.0-5.4-vc9.dll
x_debug seems to be installed properly based on phpinfo, and I have the following line in php.ini
zend_extension = "C:\Program Files (x86)\EasyPHP-12.0\php\php544x120715104042\php_xdebug-2.2.0-5.4-vc9.dll"
I've put the dll file in both the above the the ...\ext directory and tried a few variants of the above line, but I'm unable to get rid of this error message.
Any ideas?
The regular command line PHP from EasyPHP did not work as is. The problem is EasyPHP replaces the PATH variable with its own. That is just dumb that it doesn't use a different variable.
But, the following worked for me after some experimentations. I created a batch file php5.bat and placed it in C:\Windows\Sytem32 for easier access, with the following code (where C:\Program Files (x86)\EasyPHP-12.1\php\php548x121030011600 is the location my easyPHP php.exe was).
#echo off
REM Set the path for easy PHP and then start PHP.
set OLD_PATH=%PATH%
set PATH=C:\Program Files (x86)\EasyPHP-12.1
set PHP_DIR=C:\Program Files (x86)\EasyPHP-12.1\php\php548x121030011600
call "%PHP_DIR%\php.exe" -c "%PHP_DIR%\php.ini" %*
set PATH=%OLD_PATH%
#echo on
And then calling the batch file php5 -v will give you the php version. You might need to copy some DLLs from the Apache folder into the PHP folder as it will complain the DLLs are not found.
lets try to use zend_extension_tc instead of zend_extension if you're using window.
I have installed the ZendGdata PHP library into /var/www/html on my
local fedora machine. I am trying to learn to use the youtube API by
following the instructions at this link
http://code.google.com/apis/gdata/articles/php_client_lib.html
Without any changes to the "include_path", i tried opening
InstallationChecker.php in my browser and i get an exception.
PHP Extension Errors Tested
No errors found
Zend Framework Installation Errors Tested
0 Exception thrown trying to access Zend/Loader.php using
'use_include_path' = true. Make sure you include Zend Framework in
your include_path which currently contains: .:/usr/share/pear:/usr/
share/php
SSL Capabilities Errors Not tested
YouTube API Connectivity Errors Not tested
Ok. Now thats pretty normal. Next, I append the ZendGdata library path
to "include_path" using the below code at the top of InstallationChecker.php
$clientLibraryPath = '/var/www/html/phplibs/ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR .$clientLibraryPath);
Now i get an Servor 500 error when trying to open
InstallationChecker.php in the browser:) thats strange to me. If this is a
permission issue, the page should not have opened before. Right? I
disabled the above 2 lines of code and i get the error previously displayed.
(already shown above)
Any of you faced this issue? thanks in advance guys for your help...
My PHP version is 5.3 if that would help.
For php --ini, i get
[myname#localhost ~]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed: /etc/php.d/curl.ini,
/etc/php.d/dom.ini,
/etc/php.d/fileinfo.ini,
/etc/php.d/gd.ini,
/etc/php.d/json.ini,
/etc/php.d/mbstring.ini,
/etc/php.d/mcrypt.ini,
/etc/php.d/mysql.ini,
/etc/php.d/mysqli.ini,
/etc/php.d/pdo.ini,
/etc/php.d/pdo_mysql.ini,
/etc/php.d/pdo_sqlite.ini,
/etc/php.d/phar.ini,
/etc/php.d/sqlite3.ini,
/etc/php.d/wddx.ini,
/etc/php.d/xmlreader.ini,
/etc/php.d/xmlwriter.ini,
/etc/php.d/xsl.ini,
/etc/php.d/zip.ini