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!
Related
I am using the Xampp server with php5 . I have been trying to get the curl extension working. But, unable to do it. I uncommented the php_curl.dll line in php.ini. I dont see curl enabled in phpinfo() . I also copied the ssleay32.dll and libeay32.dll files to both syswow64 and system32 directories. Do i have to install anything on the server? Has anyone used xampp server before with curl ? thanks
To be honest I did not used XAMPP but couple of times I've faced problems with WAMP extensions on Windows.
Almost always reason was one of the following:
There aren't required file in /ext directory,
Extension line in php.ini is commented,
I forgot to restart server.
Also, this looks interesting (from link #1 below):
There’s a straight-forward XAMPP FAQ
Entry about their php.ini stucture.
For those looking for the easy fix,
ignore everything but the
/apache/bin/php.ini file. That’s the
only one that counts, regardless of
which PHP version you’re currently
using.
What about all the .dll files you
need? Well, you don’t need them.
Everything you need to run CURL on a
XAMPP install is included in the
download. Stop downloading extra crap
and sticking it all over your system.
XAMPP knows what it needs, where it’s
at, and how to use it. End of story.
If above steps doesn't help, read following articles (and comments):
Using CURL in XAMPP
Enable CURL with XAMPP on Windows XP
Enable Curl on Xampp
Getting cURL to Work in XAMPP
Be aware of multiple php.ini files in XAMPP. Be sure that you have edited right one.
P.S. I've just tried to enable cURL in Wamp/XP. I've removed leading semicolon ; from line ;extension=php_curl.dll and restarted server. Now I can see cURL support: enabled in phpinfo() page. I guess that's easy in XAMPP too.
Anyone faced the same thing before? I've tried the same script on a XAMPP, it worked. And I'm trying to do on a WAMP, it reported call to undefined function curl_init(). I've enabled and double-checked on my WAMP php.ini on line:
extension=php_curl.dll
The commenting was removed alright.
Could the reason be CakePHP ? I'm developing the App on Cake. Or something I need to do with WAMP...
You have to edit both these files:
wamp\bin\php\your php version\php.ini
wamp\bin\Apache\your php version\bin\php.ini
To get this problem where the side by side configuration is correct, but its still not working in wamp php 5.4.3 fixed. Follow: http://www.morningtime.com/kb/188
The php_curl.dll library is bugged and must be replaced. See attachment below. Replace the old php_curl.dll file (in your wampserver/bin/php/{version}/ext/ folder) with the new one attached. Restart Apache and you are set.
link that is currently working: http://www.morningtime.com/sites/default/files/attachments/book/188/php_curl-5.4.3-VC9-x64.zip
worked for me.
Thanks for pinpointing to checking out phpinfo() sometimes you just get too tired to test the basic. Well, after that I googled and found the solution. It seems that for a WAMP server, we need to enable both php.ini on folder PHP/..bin and Apache/..bin
I restarted after confirming both were enabled and here in phpinfo() I got curl enabled. I guess it should be working now.
or did you restart your wamp apache or what ever server you have?
EDIT:
maybe this helps. also notice the updates on top of the 1st post
How to get CURL to work with PHP on Windows? (WAMP)
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.
I just installed Apache 2.2.15/PHP 5.3.2/MySQL 5.1.44 on Windows Vista. Apache is working fine, PHP is functional, and MySQL works on the CLI. However, when I try to access MySQL via PHP, I get an error (Fatal error: Call to undefined function mysql_connect()). extension=php_mysql.dll and extension=php_mbstring.dll are uncommented in the php.ini file, and PHP is in the system path. There is no libmysql.dll in either the top level PHP directory or the ext directory. There's a libmySQL.dll file in the MySQL bin directory (which is also in the system path); I tried renaming it, but that doesn't do anything
Also, in case anyone wants to know, I originally installed PHP using the MSI installer, but it was missing some DLLs, so I installed from the zip file.
I think I've exhausted all my options. Any help on this problem would be very appreciated.
Thanks in advance.
IIRC the msi installer sets some registry values that influence the php configuration, see http://docs.php.net/configuration.changes#configuration.changes.windows. That might change the location of the php.ini that is used. You might want to delete those registry keys. Anyway, you did edit the file that is shown in the output of phpinfo()?
Which build of php do you use? The one you can download from http://windows.php.net/download/? Then you probably have the new mysqlnd transport driver built into the php core dll and don't need libmysql.dll. The mysqlnd driver should show up in the output of phpinfo(). Does it?
It sounds like you do not have the MySQL mod for PHP properly installed or configured. I recommend using AMP on Linux, so sorry for not having any specific instructions for Windows.
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.