So, I'm developing a web application at home with Linux OS and Firefox web browser. Then I deploy it on a Windows OS and a IE Web Browser.
...
Yeah I know how dumb and risky it sounds, problem is I can't afford a new computer right now, so I use Ubuntu 8.10 for developing, and the target server for my developed web app is Windows.
You know cross-browser compatibility is always a headache, and this it's all true for File Uploads.
I use PHP, and for some reason, the file upload feature wouldn't work in IE Browser. WHYYYY!!
I spent almost 3 hours on forums and finally found the reason: ENCTYPE. All file upload features warn you: You have to change your form enctype attribute to "multipart/form-data" in order that the file input contents can travel through the request.
Well... I DO! SO WHAT'S WROONG?!!
As I use an admin page with header, left navigation pane and content areas, I use the same form for several different features. And I have a feature which uploads files.
Hence, I dynamically change the ENCTYPE attribute through javascript. And after hours of trying to explain myself "why in the world is this not working if I'm doing everything right", and just before I start blaming the elves or believing I was coursed, I found this page: http://www.talkphp.com/javascript-ajax-e4x/1176-form-enctype-internet-explorer.html
It turns to be that for Internet Explorer, the W3C STANDARD enctype attribute is NOT ENOUGH. I have to set this particular ENCODING attribute as well, so my code ended up like this:
form.enctype = "multipart/form-data";
form.encoding = "multipart/form-data";
form.submit();
Yeah, I addded the form.encoding=... line and it worked perfectly.
Thanks Wildhoney @ talkphp forum!
Now I am compelled to spread the words of wisdom to all you programmers that have lost hope. No, you're not cursed, you just didn't know.
PS. Yes, my writing style today is a little bit crazy, that's what's left of an stressed mind after 3 hours of trying to find a logical reason to an error that shouldn't be there in the first time. Now I'll take some rest and no more coffee for me.
GREETINGS!
Monday, April 13, 2009
Saturday, April 4, 2009
Overcoming AJaX UTF-8 Encoding Limitation (in PHP)
I've been learning a lot about PHP, MySQL programming through a project I've been working on for 2 months.
I didn't know AJaX, actually. And when I find any challenge that takes time and a lot of headaches to overcome, I share the solution for the sake of saving people some time and bad moments.
My web application is in Spanish (latin american characters), and I use AJaX to show search results paginated, in order to make it simpler and faster to go through the results, sort them, etc...
And the results include words in Spanish, containing characters not supported in UTF-8, AJaX won't show those characters correctly.
And no, there's no way, so far I've researched, to change the UTF-8 character set for the XMLHttpRequest object; setRequestHeader("Content-Type", "...; charset=ISO...") won't work.
Some pages say you may encode the URI you are sending, and decode the responseText and you're all set. I assume encoding the URI applies when using GET method, or when using non-UTF-8 characters in the parameter values, but not to make the responseText UTF-8 compliant. I can't decode a responseText that was never encoded. And I wasn't able to decode the responseText when assigning it to the containing element.
So I finally found the solution on a web page, much simpler than what I would imagine: encode the string representing the HTML string at the server-side to UTF-8 before returning it.
In PHP, it's like this:
$html = "... all my html response text here ...";
echo(utf8_encode($html));
or whatever way you decide to do it, the fact is, encode the response text with ut8_encode() before printing it or returning it.
Also, very important, make sure the HTML page receiving the responseText has the appropriate character encoding.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I assume it'll work pretty much the same way on other programming languages; simply encode the response text server side before responding, and make sure the receiving page character set is utf-8.
Hope it is helpful for anyone.
Greetings!
I didn't know AJaX, actually. And when I find any challenge that takes time and a lot of headaches to overcome, I share the solution for the sake of saving people some time and bad moments.
My web application is in Spanish (latin american characters), and I use AJaX to show search results paginated, in order to make it simpler and faster to go through the results, sort them, etc...
And the results include words in Spanish, containing characters not supported in UTF-8, AJaX won't show those characters correctly.
And no, there's no way, so far I've researched, to change the UTF-8 character set for the XMLHttpRequest object; setRequestHeader("Content-Type", "...; charset=ISO...") won't work.
Some pages say you may encode the URI you are sending, and decode the responseText and you're all set. I assume encoding the URI applies when using GET method, or when using non-UTF-8 characters in the parameter values, but not to make the responseText UTF-8 compliant. I can't decode a responseText that was never encoded. And I wasn't able to decode the responseText when assigning it to the containing element.
So I finally found the solution on a web page, much simpler than what I would imagine: encode the string representing the HTML string at the server-side to UTF-8 before returning it.
In PHP, it's like this:
$html = "... all my html response text here ...";
echo(utf8_encode($html));
or whatever way you decide to do it, the fact is, encode the response text with ut8_encode() before printing it or returning it.
Also, very important, make sure the HTML page receiving the responseText has the appropriate character encoding.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
I assume it'll work pretty much the same way on other programming languages; simply encode the response text server side before responding, and make sure the receiving page character set is utf-8.
Hope it is helpful for anyone.
Greetings!
Monday, March 16, 2009
How to Survive an Economic Downturn - THE END
On the week of March 2nd, 2009, I received a short e-mail from Infosys, confirming my joining date on March 9th, 2009, and I have a job since then. I informed all the companies I was on recruiting process with, and thank them all for their interest in me.
I have being offered a little higher salary than before at A, my previous company, law benefits and Mayor Medical Insurance. So, in the end, patience paid, knocking on doors paid and I got a great opportunity at a solid growing company at Monterrey, Mexico.
I used initial letter acronyms to name all companies I mentioned in my blog, as they all care on their branding and image and, in the end, company name is not as relevant as the story.
If anyone read the story from start to end, thank you, and I hope it has helped you in any way. My intent was merely leave a testimony of a struggle thousands, maybe millions of people are having right now in the middle of an economical downturn, and in the end, leave a story of success to all of them, to let them know in the end, that persistence, patience and hard work get things done.
I am a catholic, and I have to say, in the name of my beliefs, that being patient to God's will always pays. Sometimes we go through hard times, and we complain, we ask for an explanation of our unfair destiny. Truth is we will never know what's fair, as man's fairness relies on selfish thoughts, and God's fairness considers it all, the best for me and all other around me. On those hard times, is when we have to thank God for all we have, faithfully let him drive our destiny and work hard walking on the path He will present before us.
Challenges will always be there. And from hard situations our self is molded. Let God mold you as a man/woman of success, he knows better than anyone what you really need, and where you are really needed.
Let's see what challenges await me here at Infosys. I'm eager to face those new challenges, and all those new opportunities ahead.
I have being offered a little higher salary than before at A, my previous company, law benefits and Mayor Medical Insurance. So, in the end, patience paid, knocking on doors paid and I got a great opportunity at a solid growing company at Monterrey, Mexico.
I used initial letter acronyms to name all companies I mentioned in my blog, as they all care on their branding and image and, in the end, company name is not as relevant as the story.
If anyone read the story from start to end, thank you, and I hope it has helped you in any way. My intent was merely leave a testimony of a struggle thousands, maybe millions of people are having right now in the middle of an economical downturn, and in the end, leave a story of success to all of them, to let them know in the end, that persistence, patience and hard work get things done.
I am a catholic, and I have to say, in the name of my beliefs, that being patient to God's will always pays. Sometimes we go through hard times, and we complain, we ask for an explanation of our unfair destiny. Truth is we will never know what's fair, as man's fairness relies on selfish thoughts, and God's fairness considers it all, the best for me and all other around me. On those hard times, is when we have to thank God for all we have, faithfully let him drive our destiny and work hard walking on the path He will present before us.
Challenges will always be there. And from hard situations our self is molded. Let God mold you as a man/woman of success, he knows better than anyone what you really need, and where you are really needed.
Let's see what challenges await me here at Infosys. I'm eager to face those new challenges, and all those new opportunities ahead.
Tuesday, February 17, 2009
Correct Installation Steps for XAMPP 1.7 on Ubuntu Linux
So, for my freelance projects, I have to learn PHP, and use MySQL as database.
I have an Ubuntu 8.10 Linux distribution, and the best tool available for developing web apps with PHP and MySQL is XAMPP (formerly LAMPP: Linux, Apache web server, MySQL database engine, PHP programming language, PERL scripting language)
XAMPP is basically a set of tools well-packed to run altogether. It is called now XAMPP and not LAMPP because it is available to all operating systems, not only Linux.
Usually the best way to install a software in Linux is to get the debian package installation, (.deb file, this is because Ubuntu is built over Debian distribution) but for XAMPP there's nota debian package; there's a self-contained .tar.gz file (like a .zip file for windows users) with a folder called lampp that includes all tools embedded.
There's a comprehensive installation manual on the XAMPP pages for installing and setting it up, however, it doesn't include some minor changes that are required in order for some included XAMPP tools (such as MySQL) to work well.
After installing XAMPP do the following:
1.- For XAMPP web page to run: give proper read/write permissions to 'others' on the lang.tmp file at /opt/lampp/htdocs/xampp folder; go to the folder and execute the following command as root user:
#chmod 666 lang.tmp
2.- For MySQL correct execution: provide read/write/execute permissions over the var folder and all its contents. As I hadn't identified the right user, I assigned it to everyone. Go to the /opt/lampp/ folder and type:
#chmod -R 777 var
I've spent HOURS figuring out in error logs and forums for the right answers. I don't even want to list all of the errors I've faced. This should solve any of your installation problems on Ubuntu 8.10 and basically any Linux distribution.
Greetings!
I have an Ubuntu 8.10 Linux distribution, and the best tool available for developing web apps with PHP and MySQL is XAMPP (formerly LAMPP: Linux, Apache web server, MySQL database engine, PHP programming language, PERL scripting language)
XAMPP is basically a set of tools well-packed to run altogether. It is called now XAMPP and not LAMPP because it is available to all operating systems, not only Linux.
Usually the best way to install a software in Linux is to get the debian package installation, (.deb file, this is because Ubuntu is built over Debian distribution) but for XAMPP there's nota debian package; there's a self-contained .tar.gz file (like a .zip file for windows users) with a folder called lampp that includes all tools embedded.
There's a comprehensive installation manual on the XAMPP pages for installing and setting it up, however, it doesn't include some minor changes that are required in order for some included XAMPP tools (such as MySQL) to work well.
After installing XAMPP do the following:
1.- For XAMPP web page to run: give proper read/write permissions to 'others' on the lang.tmp file at /opt/lampp/htdocs/xampp folder; go to the folder and execute the following command as root user:
#chmod 666 lang.tmp
2.- For MySQL correct execution: provide read/write/execute permissions over the var folder and all its contents. As I hadn't identified the right user, I assigned it to everyone. Go to the /opt/lampp/ folder and type:
#chmod -R 777 var
I've spent HOURS figuring out in error logs and forums for the right answers. I don't even want to list all of the errors I've faced. This should solve any of your installation problems on Ubuntu 8.10 and basically any Linux distribution.
Greetings!
Monday, February 16, 2009
How to Survive an Economic Downturn - A Live Testimony - Part VIII
A Light at The End of The Tunnel
Last friday I called Raquel, a director from the school I was giving classes at last year in the afternoons, to see if there were any available subjects to teach. I explained her I was currently unemployed, and I was looking for alternate ways of earning money.
Last year I quit giving classes because work was absorbing all my time and needed some space for myself.
There was not work available at school, but she referred me to X, a local, small software company providing local service for small-scale web projects. I decided to give it a shot, and the offering was just what I need today:
Work as a freelance: meaning, I am an external resource being paid for completed project, and projects last around 2 weeks to 1 month. Great! I have a way to earn money while still looking for an stable, law-benefits included job. And after getting a work, I can still be a freelance to earn and save some extra money in the middle of these hard times.
Today it was my 1st day working from home as freelance: I have to learn PHP for web apps. It is pretty easy when I have the foundations of web application development and design. That's the difference between a programmer and a software engineer; I can learn very fast, and even without knowing the code, I know the solution.
So, that give me peace of mind not to get desperate in these hard times.
And just today afternoon I recieved very good news from the company I'm willing to join, I; I received my JOB PROPOSAL! YEAH!
I accepted it so if everything comes alright, I'll be joining one of the biggest, global, fast-growing in Monterrey IT company.
I'm excited. Let's see how it turns out.
Last friday I called Raquel, a director from the school I was giving classes at last year in the afternoons, to see if there were any available subjects to teach. I explained her I was currently unemployed, and I was looking for alternate ways of earning money.
Last year I quit giving classes because work was absorbing all my time and needed some space for myself.
There was not work available at school, but she referred me to X, a local, small software company providing local service for small-scale web projects. I decided to give it a shot, and the offering was just what I need today:
Work as a freelance: meaning, I am an external resource being paid for completed project, and projects last around 2 weeks to 1 month. Great! I have a way to earn money while still looking for an stable, law-benefits included job. And after getting a work, I can still be a freelance to earn and save some extra money in the middle of these hard times.
Today it was my 1st day working from home as freelance: I have to learn PHP for web apps. It is pretty easy when I have the foundations of web application development and design. That's the difference between a programmer and a software engineer; I can learn very fast, and even without knowing the code, I know the solution.
So, that give me peace of mind not to get desperate in these hard times.
And just today afternoon I recieved very good news from the company I'm willing to join, I; I received my JOB PROPOSAL! YEAH!
I accepted it so if everything comes alright, I'll be joining one of the biggest, global, fast-growing in Monterrey IT company.
I'm excited. Let's see how it turns out.
Tuesday, February 10, 2009
How to Survive an Economic Downturn - A Live Testimony - Part VII
I've been at interviews at two new companies: VT and TS, on both everything seemed to be alright but haven't been contacted.
For the company I'm really interesting on joining, I, I haven't receive any reply upon their 2-weeks period they said they'll have an offer for me.
I don't understand: all the companies I've been at seem to be really interested on my profile, I do well, at least according to them, on the interviews, and then no reply. They say they have a position for me, they'll just follow the process to prepare a proposal, and then nothing happens.
I'm starting to get desperate: my compensation from A, the company which closed operations will be running out by the end of this month.
I have debts and no sign of a work that will guarantee my first payment on Feb 28th.
I've opened myself up, I don't pursue law benefits anymore, not even a long-term stable job, I can work in any city now.
It's sad. I feel I'm prepared, well-balanced. I don't understand what's going on.
Today I looked at all the offerings at OCC and sent my CV to several companies at any city in Mexico.
I'm starting to think if I can't find a job in IT I'll move to any job that guarantees a salary to pay my debts.
I still have hope. I have to be confident on my skills and profile; I have worked really hard and sacrificed to get to the level I have now, I would be disappointed about myself if I can't get a good job.
By the way something I noticed companies are doing on other kind of jobs: they're abusing, they're using the economical debacle as an excuse to fire people, and hire new employees with a lower salary and no benefits.
Shame on all of them. Where will this crisis end?
I know one thing for sure: things will fall by their own weight, and I won't die from hunger.
Let's see where this ends at.
For the company I'm really interesting on joining, I, I haven't receive any reply upon their 2-weeks period they said they'll have an offer for me.
I don't understand: all the companies I've been at seem to be really interested on my profile, I do well, at least according to them, on the interviews, and then no reply. They say they have a position for me, they'll just follow the process to prepare a proposal, and then nothing happens.
I'm starting to get desperate: my compensation from A, the company which closed operations will be running out by the end of this month.
I have debts and no sign of a work that will guarantee my first payment on Feb 28th.
I've opened myself up, I don't pursue law benefits anymore, not even a long-term stable job, I can work in any city now.
It's sad. I feel I'm prepared, well-balanced. I don't understand what's going on.
Today I looked at all the offerings at OCC and sent my CV to several companies at any city in Mexico.
I'm starting to think if I can't find a job in IT I'll move to any job that guarantees a salary to pay my debts.
I still have hope. I have to be confident on my skills and profile; I have worked really hard and sacrificed to get to the level I have now, I would be disappointed about myself if I can't get a good job.
By the way something I noticed companies are doing on other kind of jobs: they're abusing, they're using the economical debacle as an excuse to fire people, and hire new employees with a lower salary and no benefits.
Shame on all of them. Where will this crisis end?
I know one thing for sure: things will fall by their own weight, and I won't die from hunger.
Let's see where this ends at.
Monday, February 2, 2009
How to Survive an Economic Downturn - A Live Testimony - Part VI
So one of the doors I knocked has been opened to me, thanks to God: about a month ago I was broswing the OCC job postings, and I saw I, one of the major 3 IT companies from India, which opened offices in Monterrey around September 2007, was hiring.
So I sent my resume by e-mail to the HR contact. And two weeks ago they contacted me for an interview to be scheduled on Friday, January 30th.
It was an interesting interview, with a 2-people panel questioning me about all my knowledge both managerial and technical. It lasted an hour.
There were more people applying that day, and while waiting I spotted a fair number of partners from S both working and applying for job. I greeted them.
Interview was over, I was waiting at the reception for the results. When I arrived, I saw the HR lady approaching them and saying: "Well that will be all for now, we'll be emailing you by Tuesday next week". So when she approached me and said: "Juan Trejo, please come with me" I knew there were going to be good news.
And they were! She told me the interviewers were interested in my profile, she explained me a little bit about the company, what they do in Monterrey, primarily Maintenance projects for the moment, the job schedule, and that there were open positions with immediate requirements, she told me within 2 weeks I may receive an economical offering, that they were deciding the proffesional ranking they'll place me in within the company.
So of course, it's almost a fact until I receive the offering. By tomorrow I'll recieve more information about the company. I filled in 3 professional recommendations. I was glad to notice I had no problem on filling in the information, I have a big network, and I have good friends.
So let's wait for the offering and a closer date to start working. My economical compensation will be running out this month.
It all points to that finally my efforts are yielding great results: work a a big IT company, with law benefits, fair compensation, a growing, promising and solid company in the middle of an economical debacle.
Let's see what it turns out to be.
So I sent my resume by e-mail to the HR contact. And two weeks ago they contacted me for an interview to be scheduled on Friday, January 30th.
It was an interesting interview, with a 2-people panel questioning me about all my knowledge both managerial and technical. It lasted an hour.
There were more people applying that day, and while waiting I spotted a fair number of partners from S both working and applying for job. I greeted them.
Interview was over, I was waiting at the reception for the results. When I arrived, I saw the HR lady approaching them and saying: "Well that will be all for now, we'll be emailing you by Tuesday next week". So when she approached me and said: "Juan Trejo, please come with me" I knew there were going to be good news.
And they were! She told me the interviewers were interested in my profile, she explained me a little bit about the company, what they do in Monterrey, primarily Maintenance projects for the moment, the job schedule, and that there were open positions with immediate requirements, she told me within 2 weeks I may receive an economical offering, that they were deciding the proffesional ranking they'll place me in within the company.
So of course, it's almost a fact until I receive the offering. By tomorrow I'll recieve more information about the company. I filled in 3 professional recommendations. I was glad to notice I had no problem on filling in the information, I have a big network, and I have good friends.
So let's wait for the offering and a closer date to start working. My economical compensation will be running out this month.
It all points to that finally my efforts are yielding great results: work a a big IT company, with law benefits, fair compensation, a growing, promising and solid company in the middle of an economical debacle.
Let's see what it turns out to be.
Subscribe to:
Posts (Atom)
