Can't run PHP after a new installation of XAMPP - php

I have been a happy user of XAMPP for years,
but today I have updated to the latest Windows 32 bit version on a Windows 10 machine.
I couldn't see a 64 bit version.
Anyway, all went well,
and once I changed some settings, I was able to see all my old databases under the new phpMyAdmin.
But my PHP scripts are bombing out before they start.
Even phpinfo gives the same error message, which is...
"Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0
Fatal error: Unknown: Failed opening required 'F:/My Documents/OneDrive/Webs/htdocs/index.php'
(include_path='.;C:/xampp/php/pear/PEAR') in Unknown on line 0"
The test script of index.php is nothing more than
<?php echo "HELLO"; ?>
The statement in php.ini is
include_path = ".;C:/xampp/php/pear/PEAR"
and there are no other include_path statements.
The directory C:/xampp/php/pear/PEAR does exist.
The index.php file is there.
I don't know why there's a PEAR folder inside a pear folder - that's how Xampp installed it.
I have tried all variations of that include_path statement to no avail.
I have left out one of the pears.
Leaving out the include_path statement altogether just results in the PHP default which is a folder which is definitely not there, so that's no good.
My localhost is inside the OneDrive folder as you can see from the error message, but I have been doing it that way for years.
Now I cannot run any PHP scripts. Pure HTML is no problem.
The new installation of Xampp has totally replaced the old one, and its Control Panel v3.2.2 looks to be working perfectly.
phpMyAdmin seems to be working fine, but not phpinfo, as said.
I have scanned the web for answers to this, and there is plenty of forum Q&A's, but they all tell me to do what I have done.
The computer is Windows 10 Pro, and is fully up to date. Apache 2.4.33.
PHP 5.6.35. Database server is 10.1.31 MariaDB.
I've run out of ideas. Any help will be appreciated.
Thanks Mike.

You need to fix your include_path system variable to point to the correct location.
To fix it edit the php.ini file. In that file you will find a line that says, "include_path = ...". (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, "\xampplite\php\pear\PEAR" to read "C:\xampplite\php\pear". Make sure to leave the semi-colons before and/or after the line in place.
Restart PHP and you should be good to go. To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.

first: check all the paths in the php. ini ( use a search or a grep to check them)
second: check that you don't have any extensions added twice (one in the beginning and one in the end of the file)

Related

EasyPHP starting error after trying to change PHP

I have been using EasyPHP-12.1 for some years now but, foolishly, tried to add a different version of PHP. (I had backed up the www files but not the whole installation). I added a new version (5.6.21) to the PHP folder, selected it in the admin but it didn't work. Now the server doesn't start. It comes up with the error:
Error in Apache configuration file: AH00526: Syntax error on line 185
of C:/Server/EasyPHP/apache/conf/httpd.conf: invalid command "PHPIniDir",
perhaps misspelled or defined by a module not included
in the server configuration.
I would like to go back to the original PHP (5.4.6) or, at least, reinstall the program and copy the MySQL databases to the new installation. As I said, I have copies of all the working php pages - it's the databases that I am worried about losing.
I hope someone can get me up and running again.
I seemed to have managed to get it all working again. I found an earlier dated backup in the conf folder, renamed it and restarted. Phew!
(Made sure I am backing up all the databases and EasyPHP folder now.)

mysqli_connect() using mamp

I have MAMP up and running and can run php in my browser, but when i attempt to connect to a MySQL database the connection fails. How do I correct this? I have read that to fix this I need to "enable php_mysqli extension in PHP.ini. It’s disabled by default. look for the following line: extension=php_mysqli".
I attempted this but i have multiple PHP.ini files and the first one i clicked on did not even have the line "extension=php_mysli".
I would like to know how to fix this problem so that i can test websites on my computer and not have to upload to a web server, also once everything is set up properly what are the correct parameters for the mysqli_connect() function?
Just installed MAMP to help you, and there is no php.ini in MAMP folder.
There is just 1 file php.ini in folder:
C:\MAMP\conf\php5.6.3\
since php5.6.3 is default version for my MAMP installation.
for my MAMP installation default user for MySQL is root and password root
I had this problem, my mysqli() function seemed to not be working after using it on multiple online servers. But not on MAMP! I followed all above instructions, looking in the php.ini files.
My fix...
I had my MAMP PHP version set to 7.0.0 (standard from install)
I changed this back down to 5.6.13 to test and everything started working correctly!
Im really not sure what caused it, or how to fix it to work with higher php versions.
Maybe something fundemental has changed since version 5.6.13.
Hope this helps someone! and please respond if you know why my problem is happening!

Fatal error: Call to undefined function mysql_connect() cannot solve

I have searched this error in Google and tried everything I found, but it still does not work.
I have set in my php.ini
extension_dir ="C:\php\ext\"
uncommented
extension=php_mysql.dll
extension=php_mysqli.dll
these files are present in the extension path, and I restarted Apache.
But phpinfo(); still does not show anything about MySQL. So do you have any suggestions to load these modules?
note: I am using Windows 7 (64 bit), MySQL 5.5, Apache 2.0.49 and PHP 5.3.16
Finally, I solved the same problem, so, here is my solution. I guess the last slash in the line
extension_dir ="C:\php\ext\
could make troubles. Just let it as
extension_dir ="C:\php\ext
Moreover, try to approach the problem the following way:
*My PC is running Windows 7 (Apache 2.2 & PHP 5.2.17 & MySQL 5.0.51a), the syntax in the file "httpd.conf" (C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf) was sensitive to slashes.
You can check if "php.ini" is read from the right directory. Just type in your browser "localhost/index.php". The code of index.php is the following:
<?php
echo phpinfo();
?>
There is the row (not far from the top) called "Loaded Configuration File". So, if there is nothing added, then the problem could be that your "php.ini" is not read, even you uncommented (extension=php_mysql.dll and extension=php_mysqli.dll). So, in order to make it work I did the following step. I needed to change from
PHPIniDir 'c:\PHP\'
to
PHPIniDir 'c:\PHP'
Pay the attention that the last slash disturbed everything!
Now the row "Loaded Configuration File" gets "C:\PHP\php.ini" after refreshing "localhost/index.php" (before I restarted Apache2.2) as well as mysql block is there. MySQL and PHP are working together!*
I have been having the exact same problem as you. And I (literally) solved it 2 minutes ago.
I am running Apache 2.4 64 bit on Win 7.
The version of php I downloaded gave me two php.ini files:
1)php.ini-production and
2)php.ini-development
I thought that was all gravy and every time I made a change to one, I did the exact same thing to the other.
When I first encountered the problem I loaded index.php (on my local server) and looked at the sixth box from the top called "Loaded configuration file". It simple said "nothing."
I then referenced this page and found how PHP (once started) goes about looking for the php.ini file. I tried putting both the development and production (referenced above) files in all the directories that the above link specified. Nothing.
Then I thought, what the hell it's worth a shot, and changed the php.ini-production to just "php.ini".
Bam. It started working. Such a simplistic fix but I suppose it makes sense as to why Apache wasn't able to find "php.ini." The file didn't exist verbatim.
I really hope this helps, running into this problem sure sucked.
And I'm sorry if any of this seems patronizing because it is so simple. I always troubleshoot from this site and so many of the answers require more than a fundamental understanding of a subject, and since this seems like a problem(and a solution) that beginners will struggle with, I thought I would spell it out in a way that I would have appreciated 6 months ago.

How do I get php curl to run on my apache2.x Development server?

Before I begin, I will add that I've spent much time googling this and have attempted several solutions none of which have worked.
System Info:
Windows 7 Professional (x86, 32 bit )
Apache2 up and running C:\Program Files\Apache Software Foundation\Apache2.2\
PHP 5.3.8 C:\Program Files\PHP Also works.
manually configured httpd.conf to enable php, note that php is working, except for curl.
I have enabled curl in my php.ini C:\Program Files\PHP\php.ini
This is near the end of my php.ini
[PHP]
extension_dir = "ext"
[PHP_CURL]
extension=php_curl.dll
Note also that the file C:\Program Files\PHP\ext\php_curl.dll exists!
I have restarted the apache server and yet curl still does not function.
a quick test.php file:
<?php
$curl_conn = curl_init();
?>
note that I have both php start and end tags correct stackoverflow just isn't showing the start php tag.
puts out:
Fatal error: Call to undefined function curl_init() in E:\path\to_project\test.php on line 3
I have now spent 3 hours trying to get curl to work, google has no helped, most of the solutions seem to involve making sure that the extension=module line in php.ini is not commented out, and as you can see above it is not commented out so that advice doesn't seem to help me.
Any ideas would be appreciated as this is rather frustrating.
Thanks!
You should add "C:\PHP" to the server's PATH environment variable:
Right-click on My Computer, choose Properties
Flip to the Advanced tab
Click the Environment Variables button
Double-click the Path variable in the list of System variables.
Either add "C:\PHP;" to the beginning or ";C:\PHP" to the end (sans quotes, not both).
Restart your computer for it to take effect.
Thanks to:
http://www.webcheatsheet.com/PHP/install_and_configure.php
I know this thread has long been closed, but for anyone like myself who encounters this problem subsequently, for me, the answer turned out to be a DIFFERENT copy of the php.ini file was being loaded than what I thought. I was editing the php.ini file in my PHP 5.4.3 directory, and there is another copy of the php.ini file that resides in the Apache directory - identical as far as I could tell from a quick glance.
De-commenting the extension=php_curl.dll line IN THE RIGHT FILE, the Apache folder, enabled the curl function for me.
Jeff S.
Have you copied cURL dependency files:
libeay32.dll
ssleay32.dll
to C:\Windows\System32 folder?
It could be that PHP cannot find these two files to run cURL extension.

PostgreSQL trouble on windows PHP

I'm using WAMP on windows, which installs PHP, Apache and MySQL.
I'm now working on something new that requires PostgreSQL. The current install won't do it for me, as I keep getting these errors:
Call to undefined function pg_query()
Always
undefined function
I've installed PostgreSQL 8.3.7-1 for windows, added php_pgsql.dll,php_pdo_pgsql.dll and even libpq.dll, which a note on the PHP page for postgreSQL says Windows users need starting from PHP 5.2.6
Still, I keep getting these errors...
Can someone advise the best course of action? Or should I just uninstall apache and everything else, and do a fresh install of each component seperatly?
xampp doesn't "tell" apache/php which php.ini to use. Therefore php uses its default lookup strategy to find the .ini file. If you haven't changed anything this will be the one in the directory where the apache binary is located, xampp/apache/bin/php.ini. Did you edit this file and removed the semicolon before extension=php_pgsql.dll ?
When in doubt askecho 'php.ini: ', get_cfg_var('cfg_file_path');which file you have to edit.
xampp installs php as a module by default and you have to restart the apache in order to get php to read the php.ini again.
After thatecho extension_loaded('pgsql') ? 'yes':'no';should print yes. If it doesn't stop the apache service, open a command shell, go to your xampp directory and enterapache_start.batThis will start the apache as a console application and you can see startup errors in this console (instead of windows' event manager). If a dll is missing you will get a message box.
Did you enable it in the php ini file?
What does a call to phpinfo() say is installed for extensions?
Depending on what kind of errors you see in the Apache's error.log the answers on this question might be helpful.
I did the same as you did and got rid of the issue.But mine was for xampp. Probably you should re-install your wamp.

Categories