Category Archives: Mysql

My notes on “Getting Real” Book by 37signals

Getting Real is one of the great book by 37signals for developer, designer or entrepreneur. I love the book. A must read book. I wrote some notes from the book for myself.
So I can review it anytime. I thought it might be helpful for others so I shared my notes down. You can read the book free online Getting Real. All the credits goes to 37signals.
Thanks for writing this book.

My Notes for review

The Starting Line Chapter 2-3

  1. Deal with the actual problems you’re trying to solve instead of your ideas about those problems.
  2. Do less than your competitors to beat them.
  3. Solve your own problems. You’ll be the target audience and you’ll know what’s important and what’s not.
  4. Focus on building a quality tool that you and your customers can live with for a long time.
  5. Scope down. It’s better to make half a product than a half-assed product.
  6. Best way to know what your app should be is to know what it shouldn’t be.
  7. Keep your app small and manageable so you can actually enjoy the process.
  8. Let’s focus on what we need to focus on right now.
  9. The leaner you are, the easier it is to change.
  10. Start with a developer, a designer, and a sweeper (someone who can roam between both worlds).
  11. Metcalfe’s Law, that “the value of a communication system grows at approximately the square of the number of users of the system,”
  12. Let limitations guide you to creative solutions.
  13. Smaller companies are closer to the customer by default.
  14. Differentiate yourself from bigger companies by being personal and friendly.

    Priorities Chapter 4

  15. What does your app stand for? What’s it really all about?
  16. Work from large to small. Always.
  17. Don’t waste time on problems you don’t have yet
  18. Find the core market for your application and focus solely on them
  19. If you try to please everyone, you won’t please anyone
  20. Don’t think about scaling problem until you have one.

Feature Selection Chapter 5

  1. Build half a product, not a half-ass product
  2. Cut out the work and thinking that just don’t matter, you’ll achieve productivity you’ve never imagined.
  3. Innovation is not about saying yes to everything. It’s about saying NO to all but the most crucial features.
  4. Build something you can manage. It’s easy to make promises. It’s much harder to keep them.
  5. Build software for general concepts and encourage people to create their own solutions.
  6. Let your customers remind you what’s important. You can’t forget what’s important when you are reminded of it every day.
  7. Ask people what they don’t want. If you could remove one feature, what would it be?

Process Chapter 6

  1. Get something real up and running quickly. It’s ok to do less, skip details and take shortcuts in your process if it’ll lead to running software faster.
  2. Work in iteraions. Don’t expect to get it right the first time. Let the app grow and speak to you.
  3. Come up with ideas (Brainstorm), Sketch it in paper, Make mock up html and then go for coding.
  4. Avoid Preferences like chosing 25,50 or 100 results per page. Don’t put the burden on users while it’s your responsibility.
  5. Value the importance of moving on and moving forward. Take Decisions quickly as accepting that mistakes will happen and realize it’s no big deal as long as you can correct them quickly.
  6. Test your app via real world usage. Get real data, Get real feedback then improve based on that info.
  7. Break the Project in smaller chunks. Break 30 hours into smaller 6-7 hours.

The Organization chapter 7

  1. Unite the team. Hire people with multiple talents who can wear different hats during development.
  2. Make or manage some time at least half of your working time alone without any interruption like email response, phone call, making coffee etc. Make this time completely alone and concentrate in your work.
  3. Don’t have meetings. Reduce meetings as much as you can.
  4. Seek and celebrate small victories. “What can you do and release in 4 hours?” . A simple feature or update and release it.

Staffing Chapter 8

  1. Don’t hire unless you feel extreme necessity.
  2. Give a test project to your new employee.
  3. Hire based on open source contribution.
  4. Hire someone who can wear different hats. Designer who can also write and programmers who understand design.
  5. Hire someone who’s enthusiastic. Someone you can trust to get things done.
  6. If there is few people to fill a position hire good writers.

Interface Design Chapter 9

  1. Design the interface before start programming. Sketch it or making html is cheap and easy to change.
  2. Start designing from core of the project(epicenter). The most important piece of content first then go for 2nd important, 3rd…etc.
  3. Design for regular(The screen people see always), Blank(The screen people see first time) & Error(The screen people see when something goes wrong).
  4. Don’t focus only regular state focus also on blank slate. Because this is the first impression of your project for the users.
  5. Design for when thing goes wrong. Defensive design is like defensive driving.
  6. Consistency is not necessary. Give people what they need, when they need it and get rid of what they don’t. It’s better to be right than to be consistent.
  7. Every letter matters. You need to speak the same language as your audience too.
  8. One Interface for admin and public interface. Just build add, edit and delete function to regular application interface.

Code chapter 10

  1. Less software, less code. Keep your code as simple as possible.
  2. Choose tools that keep your team excited and motivated.
  3. Listen to your code. It will offer suggestions, it will push back and it will tell you where the pitfalls reside.
  4. Regularly put aside some time to pay off your code and design debt.
  5. Open the door for your app. Get data out into the world via RSS, APIs…etc..

Words chapter 11

  1. Don’t write a functional specifications document.
  2. Eliminate unnecessary paperwork.
  3. Write a quick story instead of details.
  4. Insert actual text instead of lorem ipsum.
  5. Think of your product as a person and give it a personality(strict, funny, serious etc..). Use them to guide copywriting, interface and the feature set.

Pricing and Signup chapter 12

  1. Give something away for free.
  2. Make it as easy as possible to get in and get out of your app for the user. Make signup and cancellation a painless process.
  3. No one likes long term contracts, early termination fees, or one time set-up fees. So avoid them. Try to make products bill on a month to-month basis.
  4. Soften the blow of bad news with advance notice and grandfather clauses.

Promotion chapter 13

  1. Go from teaser to preview o launch.
  2. Promo Site with overview, tour, screen captures and videos, manifesto , case studies, buzz, forum, pricing & sign-up and weblog.
  3. Blogging is be more effective than advertising and it’s cheaper.
  4. Share your knowledge with the world and promote through education.
  5. New or interesting features are a great way to generate buzz for your application.
  6. Check who’s is talking about you? Who’s bitching about you? Leave comments on those blogs and thanks people for posting your link.
  7. Promote upgrade opportunities inside the app.
  8. Give your app a name that’s easy to remember instead of a big name. Don’t sweat it if you can’t get the exact domain name

Support chapter 14

  1. Developers/Designers should act as also support with customer. They should hear and answer the customer.
  2. Use inline help and FAQ’s so you wont’ need a manual or training for your customers.
  3. Answer quick to your to your customer email. Don’t use more that 1 hour to answer them.
  4. Don’t consider all the request from the customer. Try to say no.
  5. User forums or chat to let customers help each other. You’ll be surprised how much want to help one another.
  6. Get bad news out to customer as soon as possible. Be honest to your customer. Good news should be trickled out slowly.

Flash(AS2) + PHP + MySql

Last couple of month was working on Flash. Became familiar with Flash and started loving it… 🙂 Then a project came they
asked for making CMS for their flash site. You can see the site http://www.zfp.com

And the game started… 🙂

Started learning AS2 and loadvars. Faced lots of difficulties and finally manged to communicate with Flash(AS2) + PHP + Mysql.
In this post I will try to give basic idea to communicate Flash(AS2) and PHP.

1. Flash(AS2)

lv_th = new LoadVars();

lv_th.onData = function(varText:String)

{

 temp = varText.split('@@');

 photo= temp[0].split('|');

 photo_title = temp[1].split('|');

 photo_description = temp[2].split('|');

};

lv_th.load("photo_gallery.php?gallery_id=5");


1. PHP+MySql


$gal_id = $_GET['gallery_id'];
$sql = "SELECT * FROM gallery WHERE gal_id=$gal_id ORDER BY gal_id";
$result = mysql_query($sql) or die(mysql_error());
$photo = array();
$photo_title = array();
$photo_description = array();

while($rows = mysql_fetch_object($result))
{
    $photo[]             = $rows->photo;
    $photo_title[]       = $rows->title;
    $photo_description[] = $rows->description;
}

print implode('|',$photo) . '@@' . implode('|',$photo_title) . '@@' .
implode('|',$photo_description);


First one is flash AS2 Code to get the data from php. It first create a new instance LoadVars();

then onload called the photo_gallery.php?gallery_id=5 and wait for the response to come.

In php we made the query based on the gallery_id and get the data and put it in three separate

array. then we implode each array values with ‘|’ and separate each array with ‘@@’.

In flash after getting the data as a string in varText variable we split it by ‘@@’ to separate the

different array values and after that separte it in ‘|’ to get each value. Now we have all the data

in photo, photo_title and photo_description array. Use the array values as you want…. 🙂

Note: In the data there should not be ‘@@’ or ‘|’. If it contains then you have to choose the separator carefully. Choose a separator which is not come as data.

Have fun with flash + php + MySql….. 😉

Preventing Duplicate Record Insertion on Page Refresh

Most of beginners (including me) face these problems inserting data into database.

When clicking submit button after filluping a form if you refresh the form it will insert the duplicate data. There are two solutions that I know from Google search. May be you can find more by Google search.

And since you cannot avoid a refresh of the screen…

<form action=”insert.php” method=”POST”>
<input type=”text” name=”name”>
<input type=”text” name=”telephone”>
<input type=”text” name=”email”>
<input type=”sumbit” name=”submit”>
</form>

1) If you are doing a form post, you might consider sending a location
header AFTER you inserted the record:

insert.php
// after inserting the data
header(“Location: thanks.php“);
exit();
// do not forget the exit, since your script will run on without it.

In that way your script will process the posting, and then redirects the
browser to thanks.php. This page will contain a message (Thank You). A reload of thanks.php will not result in a fresh db insert.

2) If you’re using sessions, generate serial and supply it as hidden field with
every posting form. Increase it at every post and decline to store data if
serial in the _POST isn’t equal to the one stored in _SESSION.

Combining it with redirects (always good to have such protection), you’ll
probably never got the duplicated submits.

Table Join

JOIN or INNER JOIN: Return only those rows when there is at least one match in both tables.

LEFT JOIN: Return all rows from the left table, even if there are no matches in the right table.

RIGHT JOIN: Return all rows from the right table, even if there are no matches in the left table.

OUTER JOIN: Return all the rows of both tables even there is no matches.