Skip to main content

Posts

A solution for PHP fopen from url issue

I had to read a web page and grab values and show on my web page by using PHP. The easiest way came to my mind was "fopen" . When I develop that on my local machine it worked perfectly but when I put that on live site it was not reading from external URL. If I need to continue on that I have to modify php.ini file to allow access which is not possible on  a shared hosting. So it was tie to Google and find a better solution. And I found one and thought to share it with you all. This following php code developed by knkk and was shared on http://www.webdeveloper.com/forum/showthread.php?t=230985 function disguise_curl($url) { $curl = curl_init(); // setup headers - used the same headers from Firefox version 2.0.0.6 // below was split up because php.net said the line was too long. :/ $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,"; $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $header[] = "Cache-Control: m...

Format Javascript

I had to analyze and change a JavaScript if it is required, but it was a big huge JavaScript file and all the code was on one line. So it was the time to find a good was to do format the JS. I found following site and thought to share it with you all. http://jsbeautifier.org/

Definer issue on MySQL

I had a main issue when I am trying to deploy a PHP, MySQL project by using CPanel. This might be occurred on any hosting provider. The issue is I have stored procedures on MySQL and when deploying it says I cannot deploy procedures which contains ‘DEFINER’ in it. So what I did is remove all the ‘DEFINER’ parts on procedures and executed the MySQL dump file. It went alright. But when we connect to PHPMyAdmin via CPanel the logged in user is same as CPanel user. On MySQL if there is no definer on a procedure it generates the currently logged in user. Now I have procedures with a CPanel user but my PHP code is connected to that DB by using a MySQL defined user. When I am trying to browse the site it throws an error saying Definer is different. Then I was in the middle of a dead lock. Then what I thought was to execute the create procedures by using PHP. Then definer will be same as PHP connected user to MySQL. So I had to write a PHP code to read the MySQL dump fil...

NASA - 2012: Beginning of the End or Why the World Won't End?

There is a big heho going on about the end of earth on 2012. But I like you to quote what NASA says about that. I believe what they say. Remember the Y2K scare? It came and went without much of a whimper because of adequate planning and analysis of the situation. Impressive movie special effects aside, Dec. 21, 2012, won't be the end of the world as we know. It will, however, be another winter solstice. Much like Y2K, 2012 has been analyzed and the science of the end of the Earth thoroughly studied. Contrary to some of the common beliefs out there, the science behind the end of the world quickly unravels when pinned down to the 2012 timeline. Below, NASA Scientists answer several questions that we're frequently asked regarding 2012. Question (Q): Are there any threats to the Earth in 2012? Many Internet websites say the world will end in December 2012. Answer (A): Nothing bad will happen to the Earth in 2012. Our planet has been getting along just fine for more than 4 bi...

Why Why there is no Trim function on JS

It was pretty bad when you find that the JS dos not have a inbuilt function on strings to do Trim. But not to worry. It can be implemented easily. function LTrim(str){ var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(0)) != -1) { var j=0, i = s.length; while (j < i && whitespace.indexOf(s.charAt(j)) != -1) j++; s = s.substring(j, i); } return s; } function RTrim(str){ var whitespace = new String(" \t\n\r"); var s = new String(str); if (whitespace.indexOf(s.charAt(s.length-1)) != -1) { var i = s.length - 1; while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1) i--; s = s.substring(0, i+1); } return s; } function Trim(str){ return RTrim(LTrim(str)); }

Download file by IE error with SSL

It took a long time to figure out what was going wrong since on all the other browsers the file was able to download but IE (6,7 & 8) . Tried a lot of things which the forums said but at last at last found the solution. Microsoft agrees this as an issue of IE and they have given the patch here.  http://support.microsoft.com/kb/323308 And also if a header was added as  "CACHE-CONTROL":"NO-CACHE" it will not work on IE even with the fix MS given. It should be changed as "Cache-control:no-store". 

JQuery API control functions

Image from hoth.entp.com I was doing JavaScript for few years and it was little bit hard to work with "write less, do more" at first few times. Always it comes to my mind as JavaScript (yes I know it is) so I am trying to apply some functions as document.getElementById. And when I wanted to hide and show elements it was style:none and block.Those look bad(when a better way is there) on jQuery and some of them may not work on jQuery elements. OK I am not here to teach you neither JavaScript nor jQuery. For the people like me it is strongly recommended (by me of course) to take a look at the available and right functions on jQuery API official site .t I just found that and thought to share that. If you got a better place or some useful links please share it.