Tag Archives: Error

How to check your php project (many files in a folder) for parse errors

Hey hadn’t wrote anything for a while here, but this is so brilliand and convenient, so I couldn’t resist to share it.

It’s about to check your project for obvious errors before releasing the changes on the production server. I found this answer in StackOverflow, but the solution is for SVN repository and while currently I am working with snv it suits me, but looking forward to migrate to Git, I was thinking “Wasn’t it nice to check the all php files within a folder?”

So here is the solution:

for i in $(find . -iname \*.php ) ; do php -l $i ; done | grep "Parse error"

This should be executed in terminal (at least in Ubuntu it is straight forward) and it print all files which had Parse errors within the folder. I think it’s a must for any php developer who release their code in production server. I already put it as alias in my .bashrc, but I will add it in my “build” script too.

Probably it could be optimized, but for me is pretty much enough.

Error: invalid XML tag syntax and Extplorer

A client of mine uses standalone version of Extplorer as Client section of his website. Because they are Studio for Printing materials, it’s normal, that their “production” is quite large as file size.

Recently they asked me to increase the max_upload_filesize to more than 4-5Gb. In the php.ini I’ve set max_upload_filesize=60G, but when someone try to login, it hangs and in the Firebug console it says “invalid XML tag syntax”.

The solution was to replace 60G with 6000G which is equivalent to ~6Gb. After that change the extplorer start working normally.

Hope this will help someone.

Check your settings while migrating Cake projects

Today I decided to restart the work of a project. The restart includes migration on the other machine as well as updating the Cakephp lib with the final version on the server.

So I copied the whole directory of the project on the second computer /which meant to be the server from now on/ and after this in the cake directory and typed “svn update”. There were some changed files and I received the latest version on the server. So far, so good.

Then I migrated the DB as well, but I decided to follow a new name convention for databases – all database names to follow the full server name i.e. for mydomain.com I would have a mydomain_com /because MySql doesn’t allow dot in the name I replaced dot with underscore/. on the old computer the database was called “mydomain”.

Ok, I changed /app/tmp permission and I decided to see what was the impact of all these actions.

Surprisingly I’ve seen blank screen instead of application screen. I said myself “sh*t, what’s happened? Does the svn update ruin everything? Am I using too old code style?”. Start digging into the code, but whatever I made there wasn’t any change on the screen. Really odd situation. do I found the second “BIG” bug in the cakePHP lib :D, well not true. Here is the explanation.

Finally after 1/2 hour I realized that I’ve changed the name of the database and the old database name doesn’t exist on the server :D. I agree, it’s stupid error and it’s all my fault, but I am wondering why there is no error message telling, that there is no such DB on the server or similar?

I know that on the home.ctp page, which is the default page when you checkout cake from the repository where you can see if the app is connected or not, but what’s happen, when you don’t use this page? Or even as it is in my other project when I rewrite the page controller and I cannot access the default start up page at all?

I think there should be a way which could notify the developers for such stupid “error” or misconfiguration. At lease if the debug level is set to 2 or 3 it should warn I guess.

The dummy mistake while coding

No body is insured from stupid mistakes while writing code. I am not insured, but subscribed for such things. 🙂

Here is the story:
Yesterday, while I was working for a small project I lost 1 hour to detect the stupidest mistake I ever made. Here I will explain what happened and how dummy I fee after that.

I am writing an application where users insert records into the database, and after that on every show of the record, there is a counter field which need to add up the number in it. Simple and easy situation.

While I was working I noticed that only one record /from 5 in the database/ got updates on his counter fields. All other had 0, while I was petty much sure that I’ve seen all these records on the screen. Well, I forced showing the 0 rows but the result was the same. Then I start investigating what could be the problem, but in the database everything was just fine. I deleted all records and started inserting texts /because there are some text fields important in this story/ one by one. Strangely, but again some of the records got update, some not. Finally /by accident/ I noticed, that counter changes when there is a space before or in the end of the value of the text I entered.
Continue reading

Google Page Rank update

Google logoYesterday, I read an article about Page Rank and how Google “punished” some popular sites with “downgrading” their PR. This happened because they had external links without attribute rel=”nofollow”.

Today I saw that Google rated my site as well. It is my first page rank. I got PR 3 and now what? Shall I make a party? Shall I cry? No! It’s one digit which telling nothing to regular people.

I don’t care what Page Rank of this page is, because it’s not commercial, but probably for some commercial project it’s quite critical.
Continue reading