Posts Tagged ‘PHP’

Monday, March 29th, 2010

If you’re like me, using EasyPHP on Windows 7 for local development and have encountered this PHP/MySQL error:

Warning: mysql_connect() [function.mysql-connect]: [2002]
A connection attempt failed because the connected party did
not (trying to connect via tcp://localhost:3306) in
C:\Path\To\Script.php on line 26

Warning: mysql_connect() [function.mysql-connect]: A connection
attempt failed because the connected party did not properly
respond after a period of time, or established connection failed
because connected host has failed to respond. in
C:\Path\To\Script.php on line 26

Fatal error: Maximum execution time of 30 seconds exceeded in
C:\Path\To\Script.php on line 26

..then you’re in luck! Here’s a quick easy fix:

  1. Go to “C:\Windows\System32\drivers\etc“.
  2. Open “hosts” with Notepad program.
  3. Uncomment this line: “127.0.0.1 localhost” or add it if it’s not on the host entry.

That’s it! Save the changes you’ve made and refresh your browser.

Hope this helps!

* NOTE - Make sure you have a full access on “hosts” file.

  1. Right click on “hosts” file then click “Properties“.
  2. On “Security” tab click “Edit…” button.
  3. Select the user that you are currently using.
  4. Under “Permissions for Users” box, tick “Full control” on “Allow” column.
  5. And then click “OK” button to apply the changes.
Sunday, May 17th, 2009

If you are a PHP developer, you know that code refactor, code completion, and code assist is a very essential features that you’ll want to have on an IDE and Adobe’s Dreamweaver couldn’t give that to you. Don’t get me wrong, I love Dreamweaver, actually I’m still using it (on my Windows desktop) for HTML and web design mockups and it’s still one of the best HTML editor out there but that’s about it, an HTML editor, nothing more.

Have you ever tried Aptana? Well you should! If you’re a Web developer, building the next biggest, greatest, and newest application of the future then Aptana will be a great tool for you. It has code refactor, PHP code completion, code assist, FTP, SFTP, and SSH support and it’s FREE (Aptana Community Edition)! Plus it also has support for Ruby (Rails), Python, Adobe Air, and other language or platform. But wait there’s more! Ajax libraries (jQuery, Prototype/Scriptaculous, Adobe Spry, Dojo, etc). And if you’re a code version control freak, no worries! It has CVS, Subversion, or Git plugin support.

Enough with the promotion! Cause I will not get paid even doing so. But if you want an IDE with tons of support and features then Aptana is one of the best out there. Especially their code assist feature, it’s a top-notch. Aptana’s code completion for PHP’s common methods are default, you’ll have to install PHP plugin first to get this feature and for Aptana to recognize PHP codes and files.

To enable PHP Code Assist in Aptana, follow the simple instructions below. This will be useful if you have classes and methods that you want to be visible all over your project.

Code Assist will only work locally which means your source file must be in your local drive (not on a remote). But there’s a workaround for this, and we’ll get to that later on.

This is how to enable PHP Code Assist:

Local Projects

  1. Click “Project” tab (found on the left panel of Aptana environment).
  2. Create a new project (right click, New -> Project…).
  3. (on New Project window, under Aptana Projects) Select “PHP Project“.
  4. Click “Next” button, type in your project name then click “Finish” button.
  5. Select and right click on the newly created project and click on “Properties“.
  6. Select “Project Natures“.
  7. Tick “com.aptana.ide.editor.php.phpnature (PHP Nature)“.
  8. Then click “Ok” button.

Remote Projects

If your working with remote files (remote server or hosted site) then steps are different but almost similar to the above.

  1. Click “Project” tab (found on the left panel of Aptana environment).
  2. Create a new project (right click, New -> Project…).
  3. (on New Project window, under Aptana Projects) Select “Existing Hosted Site“.
  4. Click “Next” button, type in your project name then click “Next“.
  5. Choose or create a new remote location (FTP or SFTP) then click “Finish” button.

    Please note that the source file needs to be downloaded into your local drive, so choose “Yes” in the Download prompt/window. Be patient and wait for the download to complete.

  6. Select and right click on the newly created project and click on “Properties“.
  7. Select “Project Natures“.
  8. Tick “com.aptana.ide.editor.php.phpnature (PHP Nature)“.
  9. Then click “Ok” button.

After doing the changes in the source file, you can use the “Smart Sync” feature of Aptana to synchronize your local and remote source files. Another cool feature of Aptana.

Hope this helps!