The problem with the HTML is that it cannot retain the values of variables from one page to the next page. All the data values of the previous page are forgotten when the next page is reloaded. To solve this problem, PHP is used. PHP allows transferring data values from one page to the next page using Forms and Hyperlinks. This is easier if the users are few but chances of confusion of data values filled by two or more different users increase when they are visiting the same webpage at the same time. To solve this problem, session handling is done in PHP.
Mysql throw error when there are special characters in query !, The characters like “`” etc are always a nuisance in sql queries.
For this reason , it’s always a necessity to use mysql_real_escape_string() (www.php.net/mysql_real_escape_string) ! , On one hand it’s secure and make sure that the queries don’t die while executing.
The syntax that should be used for mysql_real_escape_string are :-
$string = mysql_real_escape_string ($string);
Hope it helps !…..
At times Php developers need to parse domain information from a given url , Usually a $_SERVER[‘REQUEST_URI’] , The php function www.php.net/parse_url is used to extract domain name, Variables from a url string, The list of information extracted (Return values) from parse url are:-
- scheme – e.g. http, https, etc.
- host:- the domain name( www.google.com)
- port:- the number of port used
- user :- username if specified on domain url
- pass :- password if specified on domain url
- path :- path of the page after the url
- query – after the question mark ?
- fragment – after the hashmark #
Google is today one of the most important website in world wide web, Google search result has become one of the most important services for world wide web users.
A full fledged SEO industry is running on the google pagerank algorithm decided by Google Inc
I have seen a lot of developers asking the method of getting google pageranks and baclinks with the help of php. Continue reading Getting Pagerank of Websites through PHP
I am saving this for my reference , A post with all commonly used regex, The regex like saving image tags, html links , email validation etc . are one of the most common used regex !
1) Finding <img> tag through php using regex.
$pattern = ‘/<img[^>]+src[\s='”]’;
$pattern .= ‘+([^”‘>\s]+)/is’;
2) Find all links in a html page
$input = file(“page.html”);
$regexp = “<as[^>]*href=(“??)([^” >]*?)\1[^>]*>(.*)</a>”;
if(preg_match_all(“/$regexp/siU”, $response, $matches))
Usually we all get very greedy while making our url structure using .htaccess
For example, This will not work as you think
RewriteRule ^(.*)/$ category/categories.php?cat=$1 [L,QSA]
RewriteRule ^(.*)/(.*)/$ category/categories.php?cat=$1&name=$2 [L,QSA] Continue reading Correct .htaccess structure