Common mistakes and points to remember in MySQL

Some common mistakes we often commit while coding in PHP to access MySQL DB (Database). 1. For SELECT, SHOW, DESCRIBE, EXPLAIN and other statements returning resultset, mysql_query() returns a resource on success, or FALSE on error. For other type of SQL statements like INSERT, UPDATE, DELETE, DROP, etc, mysql_query() returns TRUE on success or FALSE […]

Access Form objects in case of multiple forms

How to access form objects in case of multiple forms, using JavaScript? Assume, we have a form with the id “myform”, then form can be accessed by: var oForm = document.getElementById(‘myform’); This method can only be used only when the <form> tag has an id attribute. Another way to do it without id attribute set […]

How to show or hide text using javascript?

<head> <script> function showhide(id) { if (document.getElementById) { obj = document.getElementById(id); if ( == “none”) //check if already hidden, if yes make it appear = “”; else = “none”; //if already appearing then hide here } } </script> </head> <body> <div id=”texthide”> Your text to dispay and hide goes here</div> <a href=”#” onclick=”showhide(‘texthide’); […]

How to access elements having some Class using Javascript?

How to manipulate objects of all tags (suppose div) having some class name? It can be achieved by first fetching all the div tags (or whichever you want) using function getElementsByTagName() and then check their class name using another function className(). It gives us more flexibility apart from getElementsByID() and getElementsByName(). <head> <script type=”text/javascript”> var […]

Button tag inside anchor not working in IE

HTML button tag might not work as expected when put inside anchor tags. <a href=””><button type=”button”>Click Me to go to Experts Guide</button></a> I works well in Mozilla Firefox but in Internet Explorer (IE) nothing happens on clicking it. Workaround: Put some javascript event inside onclick event handler. Redirect (or open a new window) in javascript […]

Parse XML or HTML

Here’s a simple XML parser, with DOM Object, which can fetch values digging deep but in a few lines of code. It uses namespace functinality(XPATH). The XML document must have defined namespaces. <?php $xml = <<<EOT <?xml version=”1.0″ encoding=”UTF-8″?> <entry xmlns=”” xmlns:other=”” > <id>uYG7-sPwjFg</id> <published>2009-05-17T18:29:31.000Z</published> </entry> EOT; $doc = new DOMDocument; $doc->loadXML($xml); $xpath = DOMXPath($doc); […]

HTTP Authentication in URL not working in IE

IE (Internet Explorer) doesn’t work with user names and passwords in Web site addresses URLs (HTTP/S). Though, IE versions 3.0 to 6.0 support this. The following URL syntax may not work in Internet Explorer or in Windows Explorer, http(s):// Reason: Such URL syntax is used to automatically send username/password to a Web site which requires […]

CSS font-size property not working in Internet Explorer

CSS (Cascading Style Sheete) font-size property does not work properly in Internet Explorer (IE) if spcified in this way, font-size: small or font-size: medium In mozilla firefox, it works fine. Workaround: Use em to specify the font size e.g., <style type=”text/css”> body {font-size: 0.75em;} </style> Inheritance can cause problems, for nested tags, when em or […]