Author Archive

Yahoo instant messenger is now on Kindle?

Posted by om 10 May, 2010 (0) Comment

Kindle is very useful device, now it is possible to log into Yahoo Mail using the Kindle, turns out that you now access Yahoo Messenger with the Kindle using the Yahoo mobile service. How cool is that?
I always wanted to check my email and yahoo messenger because of my boss!
Now while I am sitting on a park I can read new PHP-MYSQL 5 EBooks and can talk with my boss without paying any thing.

Staying logged into your Yahoo messenger for long is not a good idea because it will drain your battery. Since the mobile Yahoo messenger site does not use flash or java, you will be required to manually refresh the page to see any new messages you have received.

If you want to try this out yourself, you can follow the link to the Yahoo mobile messenger site:

http://us.m.yahoo.com/p/messenger/

  • Share/Bookmark
Categories : My Gadgets Tags :

How to remove duplicate entries from a table ?

Posted by om 21 April, 2010 (0) Comment

Removing Duplicate entries from Mysql database table are really simple. I have found some times interviewer ask tricky questions like this. PHP-MYSQL Beginners  just be careful !

It can all be done with three manual SQL steps! No PHP Coding required, and it works with MySQL 4 and above versions.

Step One -

CREATE TABLE MyNewTable as
SELECT * FROM MyOldTable WHERE 1 GROUP BY [column to remove duplicates by];

Step Two – You hate to keep old table with all the duplicate entries, so drop it!

DROP TABLE MyOldTable;
RENAME TABLE MyNewTable TO MyOldTable;
  • Share/Bookmark
Categories : Mysql Interview Tags :

How to enable error reporting in MAMP ?

Posted by om 31 March, 2010 (0) Comment

In MAMP by default error_reporting is turned off. This is how you can enable all errors!

1. Find your ‘MAMP’ directory in ‘Applications’

2. Find ‘conf’ and open it up..

3. Open up php4 or php5 (depending on your enabled version)

4. Line 270 should be something like this:
error_reporting = E_ALL

5. Line 277 will be:
display_errors = Off

Change this to:
display_errors = On

6. Restart servers

Ready to go !!

  • Share/Bookmark
Categories : MAMP Tags :

How to send bulk email through email software?

Posted by om 24 February, 2010 (2) Comment

If you’re sending an email campaign to thousands or millions of user using some software then you’re going to need a reliable mail server. Most of the shared servers are not going to allow you send more email. There are a lot of restrictions and host may impose email sending restrictions which makes it impossible to send.

There are ways to send –
1. You can send emails out application your web host’s mail sending engine. This advantage is accomplished if you’re sending only a few hundred emails per month, about as soon as you go over this, your host will not allow you to send more. This option is good for sending email using online php tools so many are available please check with google :)
2. You can buy your own committed server from service provider like RackSpace.com or netatlantic.com (we are using this!) and configure it to send emails. We send 60000 emails per month without any issue, they have easy to use web interface. We just create newsletter test and send to our subscribers. It works perfectly.

3. Most effective option is using third party mail server like SMTP.com. Even if you are using shared server you can use there service if you have tones of email to send. Don’t forget to negotiate for discount if you are using there partners software!!

  • Share/Bookmark
Categories : AJAX Tags :

Weird Script in FCKeditor?

Posted by om 10 September, 2009 (0) Comment

Yesterday I found a bug in FCK editor every time when I was clicking on source code it was adding this weird script

  <input type="hidden" id="gwProxy"><!--Session data--></input><input type="hidden" id="jsProxy" onclick="jsCall();" />

in text panel.

I just struggled a lot to find solution and just though to share with all of you guys.

Problem caused by firefox add-on “browser highlighter”. So just remove “browser highlighter” add-on from your firefox and its done!

I hope you know how to remove add-on from firefox!

  • Share/Bookmark
Categories : Firefox Tags :

How to display XML output in Browser?

Posted by om 28 August, 2009 (1) Comment

To display XML file on browser use this header.

 
<?php
header("Content-type: text/xml");
 
?>
  • Share/Bookmark
Categories : PHP-XML Tags :

How to post XML using socket ?

Posted by om 28 August, 2009 (0) Comment

I had discussed posting XML over HTTP using CURL in last post. Remember that was first method.
As I had promised on earlier post I would like to share second method with you. That is socket!!
Use this code and send your XML file.

<?php
function postXMLToURL ($server, $path, $xmlDocument) {
$contentLength = strlen($xmlDocument);
$fp = fsockopen($server, 80, $errno, $errstr, 30);
fputs($fp, "POST $path HTTP/1.0rn");
fputs($fp, "Host: $serverrn");
fputs($fp, "Content-Type: text/xmlrn");
fputs($fp, "Content-Length: $contentLengthrn");
fputs($fp, "Connection: closern");
fputs($fp, "rn"); // all headers sent
fputs($fp, $xmlDocument);
$result = '';
while (!feof($fp)) {
$result .= fgets($fp, 128);
}
return $result;
}
 
function getBody ($httpResponse) {
$lines = preg_split('/(rn|r|n)/', $httpResponse);
$responseBody = '';
$lineCount = count($lines);
for ($i = 0; $i < $lineCount; $i++) {
if ($lines[$i] == '') {
break;
}
}
for ($j = $i + 1; $j < $lineCount; $j++) {
$responseBody .= $lines[$j] . "n";
}
return $responseBody;
}
 
$xmlpacket ='<AATHtlDispReq1>
<Agency>
<Iata>1234567890</Iata>
<Agent>lgsoftwares</Agent>
<Password>myapassword</Password>
<Brand>phpmind.com</Brand>
</Agency>
<Passengers>
<Adult AGE="" ID="1"></Adult>
<Adult AGE="" ID="2"></Adult>
</Passengers>
<DestCode>OGG</DestCode>
<CheckInDate>101009</CheckInDate>
</AATHtlDispReq1>';
 
 
$result = postXMLtoURL("www.yourdomain.com", "/path/",$xmlpacket);
 
$responseBody = getBody($result);
 
echo $responseBody;
?>

  • Share/Bookmark
Categories : PHP,PHP-XML Tags :

How to post XML using CURL?

Posted by om 28 August, 2009 (17) Comment

Recently I was working in a hotel booking engine and found a couple of methods to post XML to server; I thought this might be good to share with my friends who want to post xml via HTTP POST method.

There are several ways to Send XML requests via HTTP POST.
I am going to show you two ways. Both are very simple and easy.

As first approach I have used a small xml file with CURL.

 
<?php 
$xml_data ='<AATAvailReq1>'.
    '<Agency>'.
        '<Iata>1234567890</Iata>'.
        '<Agent>lgsoftwares</Agent>'.
        '<Password>mypassword</Password>'.
        '<Brand>phpmind.com</Brand>'.
    '</Agency>'.
    '<Passengers>'.
        '<Adult AGE="" ID="1"></Adult>'.
        '<Adult AGE="" ID="2"></Adult>'.
    '</Passengers>'.
'<HotelAvailReq1>'.
'<DestCode>JHM</DestCode>'.
        '<HotelCode>OGGSHE</HotelCode>'.
        '<CheckInDate>101009</CheckInDate>'.
        '<CheckOutDate>101509</CheckOutDate>'.
        '<UseField>1</UseField>'.
  '</HotelAvailReq1>'.  
  '</AATAvailReq1>';
 
 
$URL = "https://www.yourwebserver.com/path/";
 
			$ch = curl_init($URL);
			curl_setopt($ch, CURLOPT_MUTE, 1);
			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
			curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
			$output = curl_exec($ch);
			curl_close($ch);
 
?>

  • Share/Bookmark
Categories : PHP,PHP-XML Tags :

New PHP e-books

Posted by om 21 August, 2009 (0) Comment

If you are looking for any other specific book of php and mysql contact me!

  1. Beginning PHP4
  2. Integrating PHP and XML
  3. Object Oriented Programming with PHP5
  4. PHP5 MySQL Programming for the Absolute Beginner
  5. Php Mysql Programming For The Absolute Beginner
  6. PHP MySQL Programming
  • Share/Bookmark
Categories : Free PHP Books,PHP Tags :

How to delete a folder with PHP?

Posted by om 9 August, 2009 (0) Comment

To delete a file, or a folder and its contents i have compiled a recursive algorithm.
Hope this will be useful for all of you.

<?php
function rmdirr($dirname)
{
 
      // Sanity check
 
      if (!file_exists($dirname)) {
 
      return false;
 
      }
 
 
 
      // Simple delete for a file
 
      if (is_file($dirname) || is_link($dirname)) {
 
      return unlink($dirname);
 
      }       
 
      // Loop through the folder
 
      $dir = dir($dirname);
 
      while (false !== $entry = $dir->read()) {
 
      // Skip pointers
 
      if ($entry == '.' || $entry == '..') {
 
      continue;
 
      }
 
      // Recurse
      rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
 
      }
 
      // Clean up
      $dir->close();
 
      return rmdir($dirname);
 
      }
 
?>
  • Share/Bookmark
Categories : AJAX Tags :