Featured Post

Constant and Static Variables in AS 3.0

Today a question came up regarding the difference between constant fields and static fields and I thought it noteworthy to mention here as it is easy to casually use static when one’s intention is really to define a constant.  Prior to AS 3.0, const was not available. In short, a field declared...

Read More

Follow @dougrdotnet on Twitter

Snow Leopard – MySql Not Found

Posted by dougr | Posted in Mac, MySQL | Posted on 29-07-2010

Tags: , ,

0

It appears that upon installation/upgrade of Mac to Snow Leapard (OSX 10.6) that the symbolic link (alias) to MySql is removed.
I wanted to make a note here for future reference on creating an alias using terminal on Mac.  Hope this helps you as well.

Following Snow Leapard upgrade with existimg MySql instance, MySql Server will not start.  The server folder cannot be found.  In order to fix, a symbolic link needs to be created in the folder where MySql Server is installed.  The link created will provide an alias which Snow Leopard will use to find the instance.
Creating an alias:
Using terminal as sudo cd into the local folder.

$ cd /user/local/

View contents of local to get the full name of MySql instance (something like mysql-5.0.67-osx10.5-x86)

$ ls

Create the alias “mysql”:

$ ln -s /user/local/[your MySql instance name]/ mysql

Open system preferences from apple menu and start MySql Server.

HTH!

MySQL – Alter Table For Zerofill

Posted by dougr | Posted in MySQL | Posted on 19-07-2009

Tags: , , ,

0

I ran across an issue with an app I’m working where a zip code text box was accepting invalid entries.  The validation was using the db for a table of zip code ranges and comparing the user’s entry to valid ranges of codes in the db.  I didn’t at first get why a user could enter 500 for New York, as opposed to 00500, and it would validate.  I went and had a look into the table and indeed the range for New York was between 500 and 599, rather than 00500 and 00599.

Solution: Write an ALTER TABLE query to change the length required in the column to 5, add ZEROFILL, and add UNSIGNED to the table structure.

By altering the table for ZEROFILL, this will automatically add zeros before any entry which has less numerals than 5, as specified in the query.  MySQL adds UNSIGNED to a column that has a ZEROFILL attribute.  From the MySQL Docs:

If you specify ZEROFILL for a numeric column, MySQL automatically adds the UNSIGNED attribute to the column.

Here is the query to alter a table in order to change the table structure for ZEROFILL and ensure 5 digits:

ALTER TABLE [table name] MODIFY COLUMN [column name] INT(5) ZEROFILL UNSIGNED;

After altering the table the zip code validation began working as expected.  Sometimes, its just not in the code and one has to have a look around for other possibilities.  Hope this helps you out.

How To Set Up a Local Web Server on Your Mac Using MAMP

Posted by dougr | Posted in Apache, Mac, MySQL, PHP | Posted on 19-07-2009

Tags: , , , , , ,

0

MAMP, which is an acronym for Mac Apache MySQL PHP, is an application which sets up a local Web server development environment in a matter of minutes.  It includes support for all of the servers listed as part of its name (support for SQLite is also included).

MAMP provides three basic necessities for any Web application; being a Web server, a database server, and a Web application server – Apache, MySQL, and PHP respectively.  Although Apple ships Mac computers with these three servers pre-installed, setup and configuration is not abstracted into a configuration interface as provided by MAMP.

MAMP installation is simple, lets go through the process together.

See the rest of my article on Lost In Technology.