This function will check the the given url has prefixed http or https. if it is not it will prefix httpon the given url.
function prefixHttpOnUrl($url= '', $prefix=''){
if ($url == '' OR $prefix=''){
return '';
}
if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://'){
if($prefix =="http://"){
$url = 'http://'.$url;
}
else if($prefix =="https://"){
$url = 'http://'.$url;
}
else {
return '';
}
}
return $url;
}
prefixHttpOnUrl("www.phpqa.blogspot.com","http://") will return http://www.phpqa.blogspot.com
prefixHttpOnUrl("phpqa.blogspot.com","https://") will return https://phpqa.blogspot.com
prefixHttpOnUrl("http://phpqa.blogspot.com","http://") will return http://phpqa.blogspot.com
prefixHttpOnUrl("http://phpqa.blogspot.com","https://") will return http://phpqa.blogspot.com
enjoy PHP'ing
This function will check the the given url has prefixed http or https. if it is not it will prefix http on the given url.
function prefixHttpOnUrl($url = ''){
if ($url == ''){
return '';
}
if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://'){
$url = 'http://'.$url;
}
return $url;
}
prefixHttpOnUrl("www.phpqa.blogspot.com") will return http://www.phpqa.blogspot.com
prefixHttpOnUrl("phpqa.blogspot.com") will return http://phpqa.blogspot.com
prefixHttpOnUrl("http://phpqa.blogspot.com") will return http://phpqa.blogspot.com
enjoy PHP'ing
Move mysql database tables to another database.
Back up your mysql database using SSH (to dumb a database)
use this command:
mysqldump -u username -p dbname >filename.sql
then the console will ask for password and enter the db password.
The sql file will generate and save into the current folder.
please check your folder whether the sql file generated or not using 'ls' command
load mysql to a database from a sql file
use this command:
mysql -u username -p dbname < filename.sql
then the console will ask for password and enter the db password.
the sql instructions from the sql file will loaded and generated in the database.
please check the database whether the sql is loaded or not.
enjoy mysql querying.........
Popular Posts
- Mysql query for searching a value, add weightage on the number of occurances and sort based on the weight-age
- How to add or remove WWW on URLs using htaccess.
- Elgg : The most popular open source social networking platform
- php questions
- Jquery based dynamic adding and removal of html elements.
- question regarding socket
- Tips on error 'Allowed memory size of xxx bytes exhausted'
- creating dynamic elements in HTML using Javascript.
- php questions
- Contact Me