Absolutely Tech

Icon

Yes!! Its absolutely tech…

[SOLVED] Flush(), ob_flush() not working in PHP (Disabling gzip through htaccess)

Flushing the output buffer doesn’t works in PHP sometimes no matter what you do. I had this code which would never work on my server but would perfectly fine on localhost. This was the code.

<?php
include('common.php');
ini_set('output_buffering','on');
ini_set('zlib.output_compression', 0);
//ini_set('implicit_flush',1);
ob_implicit_flush();
for($i=0;$i<10;$i++) {
      echo $i;
      echo str_repeat(" ", 500);
      ob_flush();
      flush();
      sleep(1);
}
?>

Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Missing alphabet check (is_alpha) in PHP

Well, you might have seen a huge number of variable checks ranging from is_file(), is_array() to is_numeric() and is_int(). While developing a script today I wanted to check for alphabets. I directly used is_alpha() but to my surprise it wasn’t defined.

Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Using CodeIgniter’s Email library separately

I’ve developed my own libraries for rapid development of PHP applications. Email library is one area which I didn’t feel like developing a library for. Just then, I remembered how simple and robust CodeIgniter’s Email class was. I decided to try it on my own script. It was not at all difficult to get it working. It just commented out few lines of codes and voila! I was able to send my first email.

Those who are in need of a email library could use this simple library separately. I’ll guide you through the whole process step by step.

First thing you need to do is copy the Email.php from system/libraries folder and place it inside your script. Then use your favorite IDE to edit these lines:
Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Installing a web server package for PHP development

So, you thought you would make a web application but didn’t know where to start?
This is the place to start. You need a web server installed on your computer before you start any kind of web programming be it PHP, ASP .Net, ColdFusion, JSP.

For developing in PHP, you would have to install an Apache HTTP server, php interpreter, MySQL server. Installing all of them would be a real headache and so would be configuring them to work with each other. To simply this we have WAMPs(Windows Apache, MySQL, PHP).

One such WAMP distribution is XAMPP which is cross platform and has many features inbuilt like filezilla ftp server, a mercury mailing server etc.

To install XAMPP first download the installer file for your OS from the following link:
http://www.apachefriends.org/en/xampp.html

Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Get Auto Increment value from MySQL table

Many a times we require the next Auto Increment value from a MySQL table. Most of the people would do something like this:

$query = "Select MAX(id) from users";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
$maxid = $row['MAX(id)'];
echo $maxid;

This would give correct results but if we delete the latest row, it will start to give wrong results.

We’ve got another query which can be used to get correct ‘Auto Increment’ values from the table.
Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Solution to “MySQL Server Has Gone Away” Problem

Seriously guys, I got this error and I was laughing hard. The error is just too funny, don’t you think? Yes, it is but not for developers like me. Problem to this error is almost undetectable and there are more than a dozen reasons as to why this occurs and this often baffles developers.

This error generally comes when :

MySQL connection times out.

The MySQL server shuts down.

The connection is interrupted.

The query you are performing is too large for server to handle.

The query you are performing takes more space than allowed (default: 16MB).

While these are some common reasons, there maybe some unknown reasons to come across this error. I faced one of those unknown reasons. Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Searching for a text string in all files and directories recursively in PHP

Sometimes you need to edit some part of your website and unfortunately it isn’t made by you. You will, obviously, need to search for the file in which that particular part of site exists. In CMSs/forums/blogs, it get really hard to search it manually.

I was having a similar problem. I needed to edit the footer of my site http://www.techmindz.com but I didn’t know which file, out of 100s, had that particular part. I just made a script for that. Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Make A PDF File In PHP (Convert HTML to PDF using PHP)

In a recent project, I had to output to a PDF file as well as to the browser. For this purpose first I downloaded the library from here. Then this code:

Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

An alternative to cross-domain AJAX, sort of

Recently, I got a project to make an ad system for a website. The ad system was such that, when the page displaying ad was loaded for the first time, it would create a random link and store them in database. From then on, it would display the same link on same page.

So, I made a javascript file which would create and xmlobject for AJAX request. It would query php file on a server and get the link. But cross domain AJAX just doesn’t work. I tried to edit some parts of it, but it just wouldn’t work. Cross domain ajax requests aren’t allowed for security purposes.

So I had to think of something else. First I thought of renaming php file to js and then addind a code to .htaccess to make it behave like php. Then I thought of making image links dynamically using php’s GD library.
Read the rest of this entry »

Post to Twitter Post to Yahoo Buzz Post to Delicious Post to Digg Post to Facebook Post to MySpace Post to Reddit Post to StumbleUpon

Number Of People Who Visited This Blog

[ 44736 ]

Email subscription

Enter your email address: