Skip to main content

Posts

Showing posts from April, 2011

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...