<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8049069912752682944</id><updated>2012-01-27T07:07:02.915-08:00</updated><category term='search engine'/><category term='hacking'/><category term='redirection'/><category term='form validation'/><category term='php'/><category term='classes'/><category term='Mysql'/><category term='Injection'/><title type='text'>PHP MySQL script</title><subtitle type='html'>Useful php and mysql script</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-6928969965014927026</id><published>2011-12-14T09:01:00.000-08:00</published><updated>2012-01-25T21:12:12.548-08:00</updated><title type='text'>Common PHP code mistakes</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;"&gt;&lt;pre&gt;&lt;span style="font-family: Verdana;"&gt;&lt;br /&gt;&lt;b&gt;1. Use empty() insted of isset() ; &lt;/b&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="color: blue;"&gt;Isset() &lt;/span&gt;checks if a variable has a value including ( Flase , 0 , or Empty string) , But not NULL. &lt;br /&gt;In other words, a variable is set if it has been assigned a value other than NULL.&lt;br /&gt;&lt;br /&gt;On the other hand the &lt;span style="color: blue;"&gt;empty() &lt;/span&gt;function checks if the variable has an empty value empty string , 0, NULL ,or False. &lt;br /&gt;Returns FALSE if var has a non-empty and non-zero value. &lt;br /&gt; &lt;br /&gt;In other words, a variable is empty if it is an empty string, 0, “0″, false, NULL, array(), and an unset variable are all empty. &lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family: Verdana;"&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;        $var = NULL;&lt;br /&gt;        &lt;br /&gt;        if(isset($var)){&lt;br /&gt;            echo " I am set". PHP_EOL;            &lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;        if(empty($var)){&lt;br /&gt;            echo " I am empty". PHP_EOL;&lt;br /&gt;        }&lt;br /&gt; ?&amp;gt;&lt;br /&gt; &lt;br /&gt; Output : &lt;br /&gt;        &lt;br /&gt;        I am empty&lt;br /&gt;&lt;br /&gt; &amp;lt;?php&lt;br /&gt; &lt;br /&gt;        $var = '';&lt;br /&gt;         &lt;br /&gt;        if(isset($var)){&lt;br /&gt;            echo " I am set". PHP_EOL;&lt;br /&gt;        }&lt;br /&gt;         &lt;br /&gt;        if(empty($var)){&lt;br /&gt;            echo " I am empty". PHP_EOL;&lt;br /&gt;        } &lt;br /&gt;        &lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family: Verdana;"&gt;&lt;span style="color: black;"&gt;&lt;b&gt; Output :&lt;/b&gt; &lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am set&lt;/span&gt;&lt;span style="color: black;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I am empty&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;i style="color: lime;"&gt;Note:&lt;/i&gt; Now when you are validating forms to make sure a user did not leave a form field blank, it is probably best to use neither empty() or isset(). Since it is possible your form might accept 0 as a valid answer. Therefore you should just check to make sure it is not an empty string.&lt;br /&gt;&lt;pre class="php" name="code"&gt; &lt;br /&gt;&amp;lt;?php&lt;br /&gt;&lt;br /&gt;if($_GET['var'] == "") {&lt;br /&gt;    echo "You must enter a value for var!". PHP_EOL;&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-6928969965014927026?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/6928969965014927026'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/6928969965014927026'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/12/common-php-code-mistakes.html' title='Common PHP code mistakes'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-7175785743388065970</id><published>2011-12-12T18:35:00.000-08:00</published><updated>2012-01-25T21:14:45.146-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>HTTP Headers in php</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;You can add headers to the HTTP response in PHP using the  Header() function.  Since the responseheaders are sent before any of the actual response data, you have to send these headers beforeoutputting any data.  So, put any such header calls at the top of your script.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Redirection&lt;/b&gt;&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;    header('Location: http://www.php.net');&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Setting a Last-Modified Header&lt;/b&gt;&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt; header('Last-Modified: '.gmdate('D, d M Y H:i:s',getlastmod()).' GMT');&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Avoid all Caching&lt;/b&gt;&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt; header('Cache-Control: no-cache, must-revalidate');&lt;br /&gt; header('Pragma: no-cache');&lt;br /&gt; header('Expires: Mon,13 Jal 1980 05:00:00 GMT');&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-7175785743388065970?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/7175785743388065970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/7175785743388065970'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/12/http-headers-in-php.html' title='HTTP Headers in php'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-6570028116998490849</id><published>2011-12-10T11:10:00.001-08:00</published><updated>2012-01-25T21:17:12.847-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mysql'/><title type='text'>Export data to CSV from MySQL</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;Many times I get request from client for data dump. I use mysql database, and in mysql it is quite &lt;br /&gt;easy to create CSV files directly from MySQL with just one query!&lt;br /&gt;&lt;br /&gt;Let's say you want to export the email and name fields from your member table to a CSV file. Here is your code:&lt;br /&gt;&lt;br /&gt;&lt;pre class="sql" name="code"&gt;SELECT email, name INTO OUTFILE '/tmp/data_dump_member.csv'&lt;br /&gt;FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'&lt;br /&gt;LINES TERMINATED BY '\n'&lt;br /&gt;FROM member&lt;br /&gt;&lt;/pre&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: lime;"&gt;Note &lt;/span&gt;: Make sure your MySQL server has write permissions to the location where you want to store the results file.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;You can either download the csv file from server's '/tmp' directory, or you can move this to http root directory and send link to client to download.&lt;br /&gt;&lt;pre class="php" name="code"&gt;cd /tmp/&lt;br /&gt;mv data_dump_member.csv /var/www/html/&lt;br /&gt;gzip -9 data_dump_member.csv&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-6570028116998490849?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/6570028116998490849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8049069912752682944&amp;postID=6570028116998490849' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/6570028116998490849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/6570028116998490849'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/12/export-csv-directly-from-mysql-query.html' title='Export data to CSV from MySQL'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-2871976299059111380</id><published>2011-12-10T10:41:00.001-08:00</published><updated>2012-01-25T21:22:41.614-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>OOP Programming with php</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Object Oriented programming requires a different way of thinking how you construct your applications. Objects enable you to more closely model in code the real-world tasks, processes and ideas that your application is designed to handle. You can think of a class as a blueprint for constructing an object, you can build multiple instance of an object.&lt;br /&gt;&lt;br /&gt;Lets start with creating a simple class example &lt;br /&gt;&lt;br /&gt;Class begins with keyword Class and followed by a name that isn't reserved word in php.  It contains the definition of methods, members and attributes of a class.&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;class demo{&lt;br /&gt;&lt;br /&gt;    private $_name;&lt;br /&gt;&lt;br /&gt;    public function __construct($name){&lt;br /&gt;        $this-&amp;gt;_name = $name;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public function getName(){&lt;br /&gt;        return $this-&amp;gt;_name;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public function setName($name){&lt;br /&gt;        $this-&amp;gt;_name = $name;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public function __destruct(){&lt;br /&gt;    &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;The contructor to this object set class property 'name'.&amp;nbsp; The accessor method getname(), enable you to fetch the value of the private member variable. Similarly, the setname() method enable you to assign a new value to variable.&lt;br /&gt;&lt;br /&gt;In test_demo.php, write following lines&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;require_once('class_demo.php');&lt;br /&gt;try {&lt;br /&gt;    $objdemo = new Demo('example1');&lt;br /&gt;    echo "Class name is : ". $objdemo-&amp;gt;getName();&lt;br /&gt;    $objdemo-&amp;gt;setName('Example2');&lt;br /&gt;    echo "Class new name is : " . $objdemo-&amp;gt;getName();&lt;br /&gt;} catch(Exception $e) {&lt;br /&gt;    echo "There was a problem :" . $e-&amp;gt;getMessage();    &lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;Access this file in your favourite browser, output should be somethink like following :&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class name is : example1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class new name is : example2&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-2871976299059111380?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/2871976299059111380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8049069912752682944&amp;postID=2871976299059111380' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/2871976299059111380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/2871976299059111380'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/12/oop-programming-with-php.html' title='OOP Programming with php'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-8744242416290945001</id><published>2011-11-27T01:40:00.001-08:00</published><updated>2012-01-25T21:24:49.393-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='redirection'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><category scheme='http://www.blogger.com/atom/ns#' term='search engine'/><title type='text'>How to Redirect a Web Page</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;This post describes how to properly redirect a web page using an HTTP 301 status code and Location header. The 301 status code is used to indicate that a page has permanently moved. 301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. PHP redirect tells the browser (or a search engine bot) that the page has been permanently moved to a new location.&lt;br /&gt;&lt;div&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;// Permanent redirection&lt;br /&gt;header("HTTP/1.1 301 Moved Permanently");&lt;br /&gt;header("Location: http://www.new-domain.com/");&lt;br /&gt;exit();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;If you set the Location header by itself, PHP automatically sets the status code to HTTP/1.1 302 Found&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: red;"&gt;Note:&lt;/span&gt; if you attempt to send headers after content has been sent, you will get a warning like, "Warning: Cannot modify header information - headers already sent by ...". Look for empty lines and spaces between PHP open and close tags.&lt;br /&gt;&lt;br /&gt;&lt;i&gt;&lt;span class="Apple-style-span" style="color: lime;"&gt;Tip:&lt;/span&gt; Use lower-case name for the header function (not Header) to make sure your PHP redirect code is compatible with PHP 6.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;You can redirect the page to new location along with parameters; this PHP code will redirect users to new location along with its query string:&lt;br /&gt;&lt;pre class="php" name="code"&gt;&amp;lt;?php&lt;br /&gt;header("HTTP/1.1 301 Moved Permanently");&lt;br /&gt;header("Location: http://www.new-domain.com".strtolower($REQUEST_URI));&lt;br /&gt;exit();&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-8744242416290945001?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/8744242416290945001/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8049069912752682944&amp;postID=8744242416290945001' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/8744242416290945001'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/8744242416290945001'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/11/how-to-redirect-web-page.html' title='How to Redirect a Web Page'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-5882747874037064134</id><published>2011-11-26T10:54:00.000-08:00</published><updated>2011-11-26T12:00:42.061-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mysql'/><category scheme='http://www.blogger.com/atom/ns#' term='Injection'/><category scheme='http://www.blogger.com/atom/ns#' term='form validation'/><category scheme='http://www.blogger.com/atom/ns#' term='hacking'/><title type='text'>SQL injections</title><content type='html'>&lt;div&gt;&lt;b&gt;what is SQL Injection?&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;SQL injection is defined as a technique that takes advantage of non-validated input vulnerabilities and inject SQL commands through a web application that are executed in a back-end database. Programmers use sequential SQL command with client supplied parameters making it easier for attackers to inject commands. Attackers can easily execute random SQL queries on the database server through a web application.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;how does it work?&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;While performing SQL injection, attackers look for pages which allows the submission of data to the backend database, such pages are login page, search page, feedback page, registration page.&lt;/div&gt;&lt;div&gt;Attackers use simple test to find vulnearabilities by simply passing single quotation mark in fields.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;how to retrieve any data?&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To check for input vulnerabilities, use single quotes. For e.g type in use name text box &lt;span class="Apple-style-span"&gt;' OR 1=1--&lt;/span&gt;&lt;/div&gt;&lt;div&gt;this can be used in input box or even in the URL of the web page.&lt;/div&gt;&lt;div&gt;If there is a match, it will login without valid username and password. &lt;/div&gt;&lt;div&gt;Followings are few more inputs attakers may try&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;' OR 1=1--&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;" OR 1=1--&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;' OR 'a'='a&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;" OR 'a'='a&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0); "&gt;') OR ('a'='a&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;SQL injection tools&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;SQLDict&lt;/li&gt;&lt;li&gt;SQLExec&lt;/li&gt;&lt;li&gt;sqlbf&lt;/li&gt;&lt;li&gt;SQLSMack&lt;/li&gt;&lt;li&gt;SQL2.exe&lt;/li&gt;&lt;li&gt;SQlPoke&lt;/li&gt;&lt;li&gt;NGSSQLCrack&lt;/li&gt;&lt;li&gt;SQLPing&lt;/li&gt;&lt;li&gt;sqlmap&lt;/li&gt;&lt;li&gt;sqlninja&lt;/li&gt;&lt;li&gt;SQLIer&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;Preventing sql injection attacks&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;ol&gt;&lt;li&gt;Never trust the input of users: check the text box entires by using the validation controls, regular expressions, code etc&lt;/li&gt;&lt;li&gt;Never use dynamic SQL&lt;/li&gt;&lt;li&gt;Do not connect to a database using an root level account, use a limited access account.&lt;/li&gt;&lt;li&gt;Do not reveal much information in error messages.&lt;/li&gt;&lt;/ol&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-5882747874037064134?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/5882747874037064134/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8049069912752682944&amp;postID=5882747874037064134' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/5882747874037064134'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/5882747874037064134'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2011/11/sql-injections.html' title='SQL injections'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8049069912752682944.post-589841153324877348</id><published>2008-02-22T13:12:00.000-08:00</published><updated>2012-01-25T21:04:40.767-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='classes'/><category scheme='http://www.blogger.com/atom/ns#' term='php'/><title type='text'>autoload class</title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The __autoload() magic function is used to dynamically load classes. Whenever PHP encounters a non-existent class, it will first call the __autoload() function, and only then declare an error. This can be used to load classes on-the-fly.&lt;/div&gt;&lt;pre class="php" name="code"&gt; &lt;br /&gt;error_reporting (E_ALL);&lt;br /&gt;if (version_compare(phpversion(), '5.1.0', '&amp;lt;') == true) { die ('PHP5.1 Only'); }&lt;br /&gt;&lt;br /&gt;// Constants:&lt;br /&gt;define ('DIRSEP', DIRECTORY_SEPARATOR);&lt;br /&gt;&lt;br /&gt;// Get site path&lt;br /&gt;$site_path = realpath(dirname(__FILE__) . DIRSEP . '..' . DIRSEP) . DIRSEP;&lt;br /&gt;define ('site_path', $site_path);&lt;br /&gt;&lt;br /&gt;$registry = new Registry;&lt;br /&gt;&lt;br /&gt;// Set some data&lt;br /&gt;$registry-&amp;gt;set ('name', 'Don');&lt;br /&gt;&lt;br /&gt;// Get data, using get()&lt;br /&gt;echo $registry-&amp;gt;get ('name');&lt;br /&gt;&lt;br /&gt;// Get data, using array access&lt;br /&gt;echo $registry['name']&lt;br /&gt;&lt;br /&gt;function __autoload($className) {&lt;br /&gt;// Assume that all class files are located in the same dir and subdirs&lt;br /&gt;$fname = str_replace('::', DIRECTORY_SEPARATOR, $className) . '.php';&lt;br /&gt;if(is_file($fname)) {&lt;br /&gt;include_once($fname);&lt;br /&gt;return;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$namespace = substr($className, 0, strrpos($className, '::'));&lt;br /&gt;$localClassName = substr($className, strrpos($className, '::') + 2);&lt;br /&gt;if($namespace) {&lt;br /&gt;eval("namespace $namespace;&lt;br /&gt;class $localClassName {&lt;br /&gt;function __construct() {&lt;br /&gt;throw new Exception('Class $namespace::$localClassName not found');&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static function __callstatic(\$m, \$args) {&lt;br /&gt;throw new Exception('Class $className not found');&lt;br /&gt;}&lt;br /&gt;}");&lt;br /&gt;} else {&lt;br /&gt;eval("class $className {&lt;br /&gt;function __construct() {&lt;br /&gt;throw new Exception('Class $className not found');&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;static function __callstatic(\$m, \$args) {&lt;br /&gt;throw new Exception('Class $className not found');&lt;br /&gt;}&lt;br /&gt;}");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;br /&gt;&lt;br /&gt;//Now, to test this, you can use the following code:&lt;br /&gt;&lt;br /&gt;vars[$key]) == true) {&lt;br /&gt;throw new Exception('Unable to set var `' . $key . '`. Already set.');&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;$this-&amp;gt;vars[$key] = $var;&lt;br /&gt;return true;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function get($key) {&lt;br /&gt;if (isset($this-&amp;gt;vars[$key]) == false) {&lt;br /&gt;return null;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return $this-&amp;gt;vars[$key];&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function remove($var) {&lt;br /&gt;unset($this-&amp;gt;vars[$key]);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Class Registry Implements ArrayAccess {&lt;br /&gt;function offsetExists($offset) {&lt;br /&gt;return isset($this-&amp;gt;vars[$offset]);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function offsetGet($offset) {&lt;br /&gt;return $this-&amp;gt;get($offset);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function offsetSet($offset, $value) {&lt;br /&gt;$this-&amp;gt;set($offset, $value);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function offsetUnset($offset) {&lt;br /&gt;unset($this-&amp;gt;vars[$offset]);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8049069912752682944-589841153324877348?l=www.phpmysqlscript.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://www.phpmysqlscript.com/feeds/589841153324877348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8049069912752682944&amp;postID=589841153324877348' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/589841153324877348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8049069912752682944/posts/default/589841153324877348'/><link rel='alternate' type='text/html' href='http://www.phpmysqlscript.com/2008/02/autoload-class.html' title='autoload class'/><author><name>admin</name><uri>http://www.blogger.com/profile/03953316077653464982</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
