Php not loading extension - php

This is my second post (original https://stackoverflow.com/questions/33463744/php-not-loading-extensions-or-anything-from-php-ini) - Im new to this whole thing and accidently hit answer instead of reply.
I am running on a mac with apache loaded from xampp.
Im trying to get an extension (ZMQ) loaded in php. It is loaded fine in the terminal php (checking it with php-i). However in a browser it is not loaded. I edited the php.ini (based on the location of the php.ini (as said in path from phpinfo) and no matter what I do it doesnt load. It actually seems like editing the php.ini file does nothing.
I have restarted the apache server. Any ideas,
Thanks so much for your help, JB

Related

my "phpinfo.php" file loads a completely blank page in both firefox and safari [duplicate]

This question already has answers here:
PHP code is not being executed, but the code shows in the browser source code
(35 answers)
Closed 7 years ago.
Background: I want to learn PHP and in the tutorial that I'm doing, one of the first things it has you do after getting PHP and mySQL going is to to test it by making a phpinfo.php file and opening it.
Problem: In FireFox, the file loads a blank page. In Safari it only shows the code that I wrote: <?php phpinfo(); ?>.
Steps so far (not necessarily in order):
I followed the steps at http://coolestguidesontheplanet.com/how-to-install-php-mysql-apache-on-os-x-10-6/
I have made a phpinfo.php file using text editor in plain text mode (as opposed to rich text) and saved that in my "sites" folder. This is the only line in that file:
<?php phpinfo(); ?>
In system preferences, I have web sharing turned on and mySQL server running. I have removed the # from in front of the load php 5 module line in the httpd.conf file as per the tutorial I mentioned. I've tried restarting the web server using "sudo apachectl restart" and then restarting Firefox.
I looked for a php.ini file in my etc folder. There wasn't one but I did find a php.ini.default. I duplicated that file and renamed the duplicate to php.ini. I'm not sure this step was a correct step to take but from the little I could find on the internet it looks like somebody else has done this and I thought, why not?. (phpinfo.php loaded a blank page before and after this step)
I typed php -i | grep php.ini into terminal and got the following:
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
and a timezone warning
So I decided to look for a php.ini in the /private/etc folder and there is one there. ( The one I created was in the /etc folder not the /private/etc folder.)
I have searched the internet including this website for answers.
System info:
When typing php -v into terminal it tells me that I am using PHP 5.3.28
When typing mysql -v into terminal it tells me that I am using mySQL 5.6.10
I am running Mac OS 10.7.5 on a Macbook Pro.
FireFox version: 40.0.3
Safari version: 6.1.6
Questions:
1) Did I correctly create the php.ini file?
2) What am I missing? Why is the phpinfo file not loading in my browser?
3) Is the timezone warning important?
Make sure that your source code file has the .php extension in the end.
If you can see the code of your php file in your browser, probably your apache server is not started or it is not working properly. To set your development environment quickly, I recommend that you download an "all in one package" such as XAMPP server or WAMP server. It comes with everything that you need to get your php project working and it is very easy and quick to install.
Take a look at: https://www.apachefriends.org/index.html
Once you have installed the package, create a folder for your project and put your php file inside it. So, copy your project folder to "htdocs" folder, inside the WAMP or XAMPP path, open your browser and type the URL:
http://localhost/yourProjectFolder/phpinfo.php
You shall see your php file working on.
Good luck!

php.ini is overwritten locally whenever project is run

Okay, I've been having issues with PDO connection strings in a new VS.PHP 3.3 project.
I have found the main, apparent, cause of this is that in phpinfo() PDO drivers shows "no value".
Having scoured the net I followed all instructions and found the in php.ini
extension=php_pdo_mysql.dll
was remarked out. I unremarked and saved. This made no difference. I then noticed that
Loaded Configuration File linked to "E:\Website\Website\php.ini
which is the local project folder. Unable to see a file here I assumed it was hidden and, sure enough, when I showed the hidden file, there it was. I opened and noticed that, as above, the extension was remarked out. I amended, saved, re-ran phpinfo() and there was no change. In going back into the local php.ini all changes had reverted back.
I have changed the three php.ini files that are saved in "PHP 5.2", "PHP 5.3" and "PHP 5.4" and none of them reflect the local php.ini.
I have no idea where to go next. Really hoping someone can point out my deliberate mistake.
Panic over, problem solved.
For anyone who suffers from the same problem, this is how it is solved....
In the PHP 5.4 directory there is a config file "php-xdebug". This is where you need to change the extensions. This is where VS was overwriting from.

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.

MySQL not working with php; and crashing apache when enabled

I just recently setup a fresh install of PHP, Mysql and Apache on my Windows 2003 server. Php is working fine and my Navicat MySQL browser can connect to my tables. However no matter what I do. MySQL doesn't show in phpInfo() even though I have the extensions in my ext folder. I installed PHP via the windows binary installer. Any idea what I'm missing? I'm pretty new to PHP is this is the first time I've tried to setup my own server I'm sure I'm missing something simple. Thanks.
--- EDIT ---
So as suggested by Alan Geleynse I added the extension to my php.ini, now Apache crashes every time I try to enable php_mysql.dll any ideas on this one? I may just restart my php from scratch if this is any more trouble.
You probably need to enable the extension in your php.ini
Search through php.ini for extension and you should see a list, some of which will be commented out. If you remove the comment for MySQL, it should load the extension.
If you do not see it, you should be able to add this line to your php.ini. Make sure that the dll listed is the one you want and is located in your extension directory.
extension=mysql.dll
Seems the issue was not only a missing php_mysql.dll but I was also missing libmysql.dll The installer still borked the install of the extension files though. Oh well it happens thanks to everyone for the help.
Probably apache crashes because of missing dll. There is probably a directory 'ext' in your php installation dir. Check whether there is a 'php_mysql.dll' file in it.
Also, check for directive 'extension_dir' in your php.ini, it must point to the location of extensions directory. For example, I have php installed in 'C:\php' and 'C:\php\ext' folder in it. My php.ini contains line:
extension_dir = "C:/php/ext"
I just fixed this problem on my computer by copying libMysql.dll from the MySql server directory to c:/windows/system32/, just a few minutes ago.

a problem with creating a site in IIS 7.5 which is using PHP

I am trying to run web application scripted in PHP on windows server 2008. I have configured PHP (as fastcgi) and IIS. Everything goes fine except the following scenario.
In the php.ini document "doc_root" edited with the correct root path for my php projects which is "c:\inetpub\wwwroot\". I created a new site on IIS and mapped it's path to "c:\inetpub\wwwroot\application1". When I try to open this site, I see that somehow (IIS or PHP no idea ) does nt run my new application on the path "c:\inetpub\wwwroot\application1". It tries to run on "c:\inetpub\wwwroot\", which returns 404 of course. What am I missing here ?
Check to see whether you are changing and loading Correct php.ini file using phpinfo()
For those who have the same problem;
I have figured out the problem. setting "doc_root" is not right. As I commented that property in php.ini file it got ok.
Also checking the following url was helpful:
http://learn.iis.net/page.aspx/246/using-fastcgi-to-host-php-applications-on-iis-7/
Its written there that you can make your php web sites use seperate php.ini files. I found this link really usefull.
Don t want to choose my answer as the right one but have to. Hope this helps.

Categories