CakePHP 'Cake is NOT able to connect to the database' - php

I've looked at this post about a similar issue:
CakePHP: Can't access MySQL database
and I've tried everything they mentioned in there including:
Changing my database.php so that the 'port' attribute for both $default and $test are the location of my mysqld.sock file
Changing the 'port' attribute to the actual integer that represents the port in my my.cnf mysql config
Changing the mysql socket locations in php.ini to the location of my mysqld.sock file
I'm using ubuntu 11.04, apache 2.2.17, mysql 5.1.54, and CakePHP 1.3.10. My install of mysql and apache don't seem to match any conventions, as in, all the config files are there, they are all just in really weird places--I'm not sure why that is, but I've tried reinstalling both programs multiple times with the same results...
At any rate, I can log into mysql from the terminal and use it normally, and apache is working because I can see the CakePHP default homepage. I just can't get it to change the message 'Cake is NOT able to connect to the database'.
SOLVED: Figured it out, had to change php.ini so that extension_dir pointed to the correct directory and had to add a line extension=mysql.so.

I just got my cake php to work. OMG it sucked. I'm going to make a video tutorial on my blog when I get a chance to make it easy to install and show all the errors and how to fix them.
go into apache and turn this on in the apache modules: rewrite_module. For me in wamp, I just go to apache -> apache modules -> rewrite_module.
Then restart. I had to do this 3 times before it worked.
Then go into the php.ini and turn this on: extension=php_pdo_mysql.dll, by getting rid of the semicolon in the front of it. Then restart again.

Related

localhost/phpmyadmin config problem, conflict with previous localhost FileMaker

6 months ago, I used FileMaker platform and set my localhost for Filemaker at that time! now I want to set my localhost for phpMyAdmin, "localhost/phpMyAdmin". I have done all the things right.
But, when write "localhost" still see the below page.
I activated Apache and PHP.
I have loaded : "sudo nano /etc/apache2/httpd.conf" and deleted # before "#LoadModule php7".
I have MAC, thus I've created the "Sites" folder and added a file named index.php with the required codes in it.
I also changed DirectoryRoot and
I have done all above mentioned steps by fallowing instruction in here "https://websitebeaver.com/set-up-localhost-on-macos-high-sierra-apache-mysql-and-php-7-with-sslhttps"
I don't know what to do now ?!
I uninstalled all FileMaker Server from my computer and the problem solved without any other change!
I still wonder what should I do if I want to have two localhosts!
1- localhost port 80 for Filemaker server
2- localhost port 90 for phpMyAdmin

XAMPP phpMyAdmin Session Error

I had two XAMPP installed in my computer. XAMPP1 was in C:\XAMPP and XAMPP2 is in D:\XAMPP. Both were working fine. I needed to delete XAMPP1 (c:\xampp) and deleted. After that My XAMPP2 PHPMyAdmin Stopped Working. It displays error message something like this:
It is searching SESSION DATA in C:\XAMPP\TMP. So I created empty folder C:\XAMPP\TMP
After that it displays error message like this:
This means If I Install another xampp in C: drive it will work. But I don't want to install another xampp in C: drive. Is there any solution to this problem?
Looks like the installation in D:\XAMPP is not properly configured.
Adjust session.save_path in your php.ini. You most likely don't want the session data in the old Xampp directory.
Also check that extension_dir in your php.ini matches the correct path to your php extensions. This could be the reason that the mysqli extension is not loaded, if it's pointing to a different path.
Restart Apache and try again
Check your log files for errors, e.g. failed extension loading etc.
If the error about the missing mysqli extension persists, make sure it is not commented out in your php.ini
Edit:
Sorry, I don't have the rights to comment yet... :(
Not sure, if remote debugging is very effective here. Search the error message and have a look for example here: phpMyAdmin - #1932 Table doesn't exist (collation in use) after reinstalling

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!

trouble setting up local host and php on osx yosemite

Currently trying to setup my localhost and install php as well with the new osx yosemite
i've been following the following instructions: http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
I've uncommented everything they said for apache and php and restarted apache afterwords
FYI. SO won't let me type localhost so where I write lh means that
I'm successfully able to get to
lh/
but... if I try to go to any other pages it says the site can't be found.
There is a index.html in the Sites folder which I have tried to access lh/~myusername/index.html
and I have the same file in /Library/WebServer/Documents which I have tried to access lh/index.html
Can someone tell me the step that I am missing that needs to get all of this to work correctly?
Apache has a DocumentRoot which is the default page for localhost. That guide tries to enable a virtualhost for a directory in your local user but it is not possible to know why yours is not working as it is not clear which part you have gone wrong.
However it is better to use normal virtualhost configuration to define any folder you want for Apache as it is pretty much the same as Apache under Linux. Follow this guide for a basic understanding of creating virtualhosts for Apache. Let me know if you have any issues.
I had the same exact problem.
Followed all the steps, retraced them but still got the error.
First, check for a syntax error in your httpd.conf by typing in terminal:
sudo apachectl configtest
If you get a Syntax OK, then most likely its one of the settings in your httpd.conf file that isn't set right
You can check out this post and try what some other people did:
Apache localhost/~username/ not working
My error was that I didn't actually include "~" in the username (thought it was just there to define the var 'username' - took me almost 2 god damn hours to figure that out -__-)
After I got that far
localhost/~username
worked but I didn't have permissions to view it.
Had to do an extra step here to add permissions for my user:
http://coolestguidesontheplanet.com/forbidden-403-you-dont-have-permission-to-access-username-on-this-server/

Configure PHP to work with MySQL and phpMyAdmin

My purpose is to setup a forum in php just locally on my Windows 7 machine to test how it works.
I have installed Apache HTTP Server and PHP v5 successfully. Then I downloaded and extracted the phpbb-forum software and put it in my root folder. Then I realized that I needed some kind of database so I downloaded and installed MySQL. To configure my database I also downloaded and extracted phpMyAdmin but I can't get it to work. When I open my browser and navigate to my phpMyAdmin-folder I simply get this:
Screenshot: http://img836.imageshack.us/img836/5139/captureqb.png
I use my Apache server to preview my website where I'm using some php include functions so I know that I've a "working" PHP installation. The MySQL service is also running on my computer.
However, do you need to configure PHP and/or Apache in order to get phpMyAdmin to work properly? I'm a complete noob on this so I suppose it may be multiple shortcomings.
Thank you.. //Realiserad
The simpler way is to install WAMP server : it bundle Apache, PHP, MySQL and PHPMyAdmin preconficurated for work together.
You need to enable the MySQL extension to use MySQL from PHP.
The MySQL extension may or may not be bundled with your PHP distribution. (look for php_mysql.dll in the ext folder)
Assuming it's installed you can enable it by adding or uncommenting this line in your php.ini:
extension=php_mysql.dll
As other people have said it may be simpler to install WAMP Server
Have a look at: http://www.ricocheting.com/how-to-install-on-windows/mysql - Specifically, the 3rd step. It involves downloading the mySQL PHP Extention (which is a dll), and un-commenting a line of php.ini so that PHP Load's the extension.
While is may be simpler to install XAMPP or WAMP, I think that it's good to know how to fix your own problems - Scientia potentia est :D
not very familiar with windows, but it seems like you miss the php-mysql extension, which you can download from here (i think):
http://mysql2.mirrors-r-us.net/downloads/connector/php/index.html
would be alot easier for you to use a preconfigured wamp install like this one (available for win/mac/etc). google "xampp", i'm not allowed to post more than one link due to stackoverflows spam protection.
Configure PHP to Access MySQL
Open the c:\php\php.ini file with your favorite text editor.
Uncomment the following lines by removing the semicolon:
extension=php_mysqli.dll
extension=php_mbstring.dll
extension=php_mcrypt.dll
save and exit editor
After extracting the archive into phpmyadmin folder, you will have to configure phpmyadmin before you can connect to sql server.
you should create a configuration file. This file can be created manually (simply use a text editor),
During your first session you will see an error message.
To solve this problem you should create folder (C:\project\wwwroot\phpmyadmin\config). After that give full rights for IIS_IUSRS group and IUSR user.granting permission/image
Return to the config window. Visit localhost/phpmyadmin/setup/
To configure the connection settings click on the “New Server” button.
Enter the verbose name of the SQL server, and then the server hostname. If necessary, you can specify other settings.[setting up/image][2]
Save the settings and then the server will redirect us to the previous page. Choose:
the default language – English
the default server – 127.0.0.1
end of the line – Windows (\ r \ n)
Click Save, and then download. The received file (config.inc.php) you should save to the root directory (C:\project\wwwroot\phpmyadmin).
Open the authorization window (//localhost/phpmyadmin/) and login under root account. If you see a starting phpMyAdmin window, you can delete config folder.
For the correct work phpMyAdmin requires a database with the information. The script for creating database is already installed.

Categories