Archive for the ‘PHP’ Category

How to add line break in body for mailto

Posted: August 13, 2015 in HTML, PHP
Tags:

// PHP code

$email = 'myemail.domain.com';
$subject = addslashes("This is Subject: Let's check it...!!!");
$body = addslashes("This is message area. \r\n My Second line...Let's check it...!!!"); // body comes from text area so will have \r and \n
$body = str_replace(array("\r\n","\r","\n"),'%0D%0A',trim($body));

// HTML Code



<a onclick="mailto:<?=$email;?>?subject=<?=$subject;?>&body=<?=$body;?>" >Click here to email me</a>


Pass smarty variable to php code

Posted: July 22, 2014 in PHP
Tags:

If you want to do some complex php operation in smarty tempelate file then you can pass your smarty variable to {php} tags by following manner and then can add your login between {php} tags.


{assign var="currentName" value=`$one.name`}

{php}

echo $currentName = $this->get_template_vars('currentName');

{/php}

WAMP curl not working in local pc

Posted: July 16, 2014 in PHP
Tags: , ,

1) Enable curl extension in both php.ini ( file location shown below)

extension=php_curl.dll

D:\wamp\bin\php\php5.3.13\php.ini

D:\wamp\bin\apache\apache2.2.22\bin\php.ini

2) Download php_curl.dll from below link and replace it in D:\wamp\bin\php\php5.3.13\ext.

If your PHP version is 5.3.14 then download “php_curl-5.3.14-VC9-x64.zip” from http://www.anindya.com/php-5-4-3-and-php-5-3-13-x64-64-bit-for-windows/ under  ‘Fixed curl extensions‘ .

 

Wamp disable orange xdebug errors

Posted: June 30, 2014 in PHP
Tags:

Find following line in php.ini and comment that line and restart wamp.

;zend_extension = “d:/wamp/bin/php/php5.3.13/zend_ext/php_xdebug-2.2.0-5.3-vc9-x86_64.dll”

If you are using wamp and enabled openssl from icon tray and still you are getting this error then:

When you enable php_openssl through the WAMP UI, you enable it for Apache, not for the CLI

You need to modify C:\wamp\bin\php\php-5.4.3\php.ini.

vertically center image in div

Posted: April 16, 2014 in PHP

<!doctype html>
<html lang="en">
<head>
</head>
<body>
<style>
.cover{ float:left; margin: 10px;}
.box
{
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
background:D6D6D6;
border: 1px solid grey;
display:table-cell;
}
.container
{
vertical-align: middle;
}
.container img
{
max-height: 100px;
max-width: 100px;
}
</style>
<div class="cover">
<div class="box">
<div class="container">
<img src="https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRjWxCr7_t7KoK_WSe3UDeucvuaiyddKqk4FfqNOxUAyC0AbVRO" >
</div>
</div>
</div>
<div class="cover">
<div class="box">
<div class="container">
<img src="http://wallpaper.pickywallpapers.com/htc-hd7/preview/red-bull-logo.jpg" >
</div>
</div>
</div>
<div class="cover">
<div class="box">
<div class="container">
<img src="http://www.hdwpapers.com/thumbs/batman_logo_wallpaper_2-t2.jpg" >
</div>
</div>
</div>
<div class="cover">
<div class="box">
<div class="container">
<img src="http://wallpaper.pickywallpapers.com/lg-dare/preview/big-android-logo-on-a-blue-background.jpg" >
</div>
</div>
</div>
</body>
</html>


// Detect file input support
var isFileInputSupported = (function () {
// Handle devices which falsely report support
if (navigator.userAgent.match(/(Android (1.0|1.1|1.5|1.6|2.0|2.1))|(Windows Phone (OS 7|8.0))|(XBLWP)|(ZuneWP)|(w(eb)?OSBrowser)|(webOS)|(Kindle\/(1.0|2.0|2.5|3.0))/)) {
return false;
}
// Create test element
var el = document.createElement("input");
el.type = "file";
return !el.disabled;
})();

if (isFileInputSupported)
$('[name="myfile[]"]').trigger('click');
else
alert('This device does not support File upload.');