Posts

Why session become blank on several pages in codeigniter?

I was to irritate that session did not work or became blank on sevral pages during work on website. i tried too many short ways but they all are works for some time or some place finally i got a permanent way to store a session in mvc codeigniter. First of all go in application/config/config.php open this file and change this content $config['sess_use_database'] = FALSE; TO $config['sess_use_database'] = TRUE; and $config['sess_table_name'] = 'ci_sessions'; // sess_table_name should be " ci_sessions "  when You change this after that copy and paste this sql query in database CREATE TABLE IF NOT EXISTS `ci_sessions` (   `session_id` varchar(40) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',   `ip_address` varchar(16) COLLATE utf8_unicode_ci NOT NULL DEFAULT '0',   `user_agent` varchar(50) COLLATE utf8_unicode_ci NOT NULL,   `last_activity` int(10) unsigned NOT NULL DEFAULT '0',   `user_data` text

How to save an image with image validation in new folder in php?

If you want to save an image on a new folder which will create on run time and with image validation , then simply copy and paste this code and change the name of image field name and you can replace $id to your folder name. $id=$_POST['id']; $last_url = $_SERVER['HTTP_REFERER']; if(!empty($_FILES['uploadedfile']['name'])){ $imgExtension = array("jpg","jpe","jpeg","gif","png","GIF","JPG","JPEG"); $image_name = pathinfo($_FILES['uploadedfile']['name']); $extension = strtolower($image_name['extension']); if(in_array($extension,$imgExtension)){ $file_name = $_FILES['uploadedfile']['name']; $ext = end(explode('.',$file_name)); $folder_path = 'public/uploads/auction/'.$id; $save_path  = 'public/uploads/auction/'.$id.'/'.$file_name; $path  = 'publ

How to get alexa rank using php?

I tried to many script of alexa which return you the rank of website but they all script return 0 always. so i make a new alexa script which return exact rank of website and this works. simple copy and paste alexa script code in your php file, it will also work on localhost <?php     function alexaRank ($domain)     {         $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim($domain);         $search_for = '<POPULARITY URL';         $part='';         if ($handle = @fopen($remote_url, "r")) {         while (!feof($handle)) {         $part .= fread($handle, 100);         $pos = strpos($part, $search_for);         if ($pos === false)         continue;         else         break;         }         $part .= fread($handle, 100);         fclose($handle);         }         $str = explode($search_for, $part);         $str = array_shift(explode('"/>', $str[1]));         $str = explo

How to add slide out div in our website?

How to add slide out div in our website? <style type="text/css" media="screen">     .slide-out-div {        padding: 20px;         width: 250px;         background: #f2f2f2;         border: #29216d 2px solid;     }     </style>     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script>            <script> /*     tabSlideOUt v1.3         By William Paoli: http://wpaoli.building58.com     To use you must have an image ready to go as your tab     Make sure to pass in at minimum the path to the image and its dimensions:         example:             $('.slide-out-div').tabSlideOut({                 tabHandle: '.handle',                         //class of the element that will be your tab -doesnt have to be an anchor                 pathToTabImage: 'images/contact_tab.gif',     //relative path to the image for the tab *

The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay

The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay if you have long mysql query or many joins and you got this error the use this  SET SQL_BIG_SELECTS = 1 example:  SELECT p.id as project_id,  p.job_number, p.time_to_complete , p.user_id, p.job_name, p.bid_date , p.bid_complete_date, p.service_id, p_docs.link, p_docs.username, p.status,  p_docs.password, p_docs.special_instructions, ord.amount, ord.payment_status, p.createDate , s.service_name , u.contact_name , u.f_number , f.name as franchise_name , v.name as vendor_name ,v.id as vendor_id , s.id as services_id , ord.order_date FROM wte_projects AS p INNER JOIN wte_projects_docs AS p_docs ON p.id = p_docs.project_id INNER JOIN wte_orders AS ord ON p.id = ord.project_id INNER JOIN wte_users AS u ON u.id = p.user_id  LEFT JOIN wte_franchise as f on f.code = u.f_number LEFT JOIN wte_services AS

How to use Number Validation for text box onkeyup by javascript?

How to use Number Validation for text box onkeyup by javascript? i got stuck in this problem so i make some customize code of Number Validation for text box onkeyup by javascript. it runs good and give quick alert. you can copy and paste this code in your file and simply run the file and you can customize the code according to your need. <script type="text/javascript"> function checknum(s) { return (s.toString().search(/^-?[0-9.]+$/) == 0 ) } </script>  <input name="phone" id="phone" type="text" class="last_bg" onkeyup="if(this.value != '' &amp;&amp; !checknum(this.value)){this.value = ''; alert('Please enter numbers only!')}"  value=""/> Dont forget to add jquery.js file in this page

How to add 301 redirecting in url add www before the url?

Url rewriting in htaccess 310 for redirecting the url from website.com to www.website.com and you can use this code to add 301 redirect to your webiste to redirect the url from without www to www like http://website.com to http://www.website.com simple copy and paste this code in your htaccess file and replace the website word to your website name RewriteCond %{HTTP_HOST} ^website\.com$ [NC] RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]

How to create a CSV file from MySQL with PHP?

Create a CSV file from MySQL with PHP simple copy and paste this code to create the csv file from mysql with php and change the query according to your need. <?php mysql_connect('host','username','password'); mysql_select_db('database_name'); function remove_char($var) { $set = preg_replace('/[^a-zA-Z0-9-+@() \.\_\']/','padh',trim($var)); return $set; } function csv_create() { header("Content-type: application/csv"); header("Content-Disposition: attachment; filename=".date('Y-m-d-h:i:s').".csv"); header("Pragma: no-cache"); header("Expires: 0"); $res = mysql_query("SELECT fname,lname,fullname,email FROM cs_users order by id"); echo "First Name,Last Name,Full Name,Email\n"; // fetch a row and write the column names out to the file while($val = mysql_fetch_array($res)) { $fname = remove_char($val['fname']); $lna

How to use linkedin login api in my php website?

If you want linkedin login api for your php website and use registration with linkedin then you came on right post. here is some code for your linkedin login follow the instruction as in this post and then You can easily apply this linkedin login in your website add this code in your header Make a linkedin image the name of that image should be linkedin.jpg and place this in your images folder this image will show on linekedin button <script language="javascript" type="text/javascript" src="/js/confirmed_custom.js" ></script> <script type="text/javascript" src="http://platform.linkedin.com/in.js">   api_key: your website likedin api        // HGYbaYgas6Hfa&   onLoad: onLinkedInLoad   authorize: false </script> <script type="text/javascript"> function onLinkedInLoad() { $('a[id*=li_ui_li_gen_]') .css({marginBottom:'20px'}) .html('<img src="images/lin

How to Send Mail using SMTP and PHP?

how to use  SMTP send mail script This article is all about " send Mail using SMTP and PHP ". so now you  can send your email SMTP authentication smtp and php script. each mail needed server authentication, So you have to buy mail server. First you have to make a php file and add this code in this file and file name should be  SMTPClass.php <?php class SMTPClient { function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body) { $this->SmtpServer = $SmtpServer; $this->SmtpUser = base64_encode ($SmtpUser); $this->SmtpPass = base64_encode ($SmtpPass); $this->from = $from; $this->to = $to; $this->subject = $subject; $this->body = $body; $this->newLine = "\r\n"; if ($SmtpPort == "") { $this->PortSMTP = 25; } else { $this->PortSMTP = $SmtpPort; } } function SendMail (){ if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP)) { fputs ($SMTPIN, &qu

How to add TimeStamp in wordpress like facebook and twitter?

How to add TimeStamp in wordpress like facebook and twitter? Simply copy and paste this code to use time stamp in wordpress you can also customize this time stamp code according to your need <?php $days = round((date('U') - get_the_time('U')) / (60*60*24)); if ($days==0) { echo "Posted today"; } elseif ($days==1) { echo "Posted yesterday"; } elseif ($days<8) { echo "Posted " . $days . " days ago"; } elseif($days<30) { $week = $days/7; echo "Posted " . round($week) . " weeks ago"; } else { $Month = $days/30; echo "Posted " . round($Month) . " months ago"; } ?>

How to add move div with page scroll in website?

Div move with Scroll Simple copy and paste this code <div id="floatdiv" style="position:absolute;right:0px;top:0px;"> Move content </div> <script type="text/javascript"><!-- var floatingMenuId = 'floatdiv'; var floatingMenu = { targetX: -40, targetY: 400, hasInner: typeof(window.innerWidth) == 'number', hasElement: document.documentElement && document.documentElement.clientWidth, menu: document.getElementById ? document.getElementById(floatingMenuId) : document.all ? document.all[floatingMenuId] : document.layers[floatingMenuId] }; floatingMenu.move = function () { if (document.layers) { floatingMenu.menu.left = floatingMenu.nextX; floatingMenu.menu.top = floatingMenu.nextY; } else { floatingMenu.menu.style.left = floatingMenu.nextX + 'px'; floatingMenu.menu.style.top = floatingMenu.nextY + 'px'; } } floatingMenu.computeShifts = function () { var de = docum

facebook Send Button pick up default image from site how to change this image according to our us?

Image
when you use Facebook's Send button its shows which images and how to change this image       1st thing you have to do is: follow this link   http://developers.facebook.com/tools/debug enter the url and check the Object Properties and see the title image and description , image of facebook page . now go to header of your website and and set top of the page title , description , keywords , image for image you can paste this code and change the path of website <meta name="image" content="http://www.earlyshares.com/public/images/earlyshares-petition.png" src="http://www.earlyshares.com/public/images/earlyshares-petition.png"/> change the image name according to website which one you want to show in below the facebook send button   please clear the cache and cookie before to test this.   and confirm that meta image code should be top from the send button

internal error or misconfiguration in codeigniter or php

 internal error or misconfiguration in codeigniter or php Internal Server Error  The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator , admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. so please Make sure your apache has mod_rewrite activated LoadModule rewrite_module modules/mod_rewrite.so If it is commented out (# in front), make sure to uncomment it and save the file. Checking if the corresponding module exists may be a good idea as well (but it usually does). IN simple language go on your running wamp or xampp click on that  and go on apche section and click on httpd.conf file and search mod_rewrite.so and remove the # in the front of line (# is use for comment)

How to generate random eight digit number in php?

To random generate the 8 digit code number Simple copy and paste this code in you php file and run the file You can also customize the code <?php                     $chars = "BC0DEFG1HJK3LMO4PQRS5TUW6XYZa7bcdefg8hijklimno9pqrst";                         $res = "";                         for ($i = 0; $i < 8; $i++) {  // you can replace 8 to any number to change the length of code                         $res .= $chars[mt_rand(0, strlen($chars)-1)];                         }                         echo $coupon_code = $res;   ?>

Jquery customizable validation?

Jquery customizable validation Add latest jquery file in the top of the page <script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function() {   $('#submit').click(function() {   alert('sagar');   $(".error").hide();   var hasError = false;   var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;   var emailblockReg = /^([\w-\.]+@(?!gmail.com)(?!yahoo.com)(?!hotmail.com) (?!aol.com)([\w-]+\.)+[\w-]{2,4})?$/;   var fname = $("#fname").val();   var lname = $("#lname").val();   var Email = $("#email").val();   var password = $("#password").val();   var cpassword = $("#cpassword").val();   var address = $("#address").val();   var zipcode = $("#zipcode").val();   var state = $("#state").val();   var phone = $("#phone").val()

How to add twitter share button in our website?

Simple copy and paste this code to add a twitter link in your website  <script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script> <a href="https://twitter.com/share" class="twitter-share-button"           data-url="Your website URL"           data-via="website"           data-text="content you want to share"           data-related="name"           data-count="none">   tweet </a> Now you can share your your content on twitter.

How to get time difference between two dates in specific format?

If are looking for a time difference in  specific format like : 2min ago, 2 hour ago, 2 week ago, 2 month ago You came right place simply copy and paste this code in you php file and run the file it will return you time , date format according to your need. <?php function getdiffrenceformat($time) {     date_default_timezone_set('Asia/Kolkata');     $mintime = getDifference(date("Y-m-d H:i:s"),$time,'1');     $hourtime = getDifference(date("Y-m-d H:i:s"),$time,'2');     $daystime = getDifference(date("Y-m-d H:i:s"),$time,'3');     $weektime = getDifference(date("Y-m-d H:i:s"),$time,'4');     $monthtime = getDifference(date("Y-m-d H:i:s"),$time,'5');     $yeartime = getDifference(date("Y-m-d H:i:s"),$time,'6');         if($mintime<=60)         {             return $mintime.' min ago';         }         elseif($hourtime<=24)         {  

How to separate url into a embed code of youtube?

how to separate url from a embed code of youtube ? there is a solution for Get url into a  embed code of youtube function getyoutubeVideolink ($code){     $a = array();     $b = array();     $c = array();     $a = explode('src',$code);     $b = explode('frameborder',$a[1]);     $b = explode('frameborder',$b[0]);     $c = explode('"',$b[0]);     return $c[1];     } $embed_code = '<iframe width="420" height="315" src="http://www.youtube.com/embed/GwQMnpUsj8I" frameborder="0" allowfullscreen></iframe>'; $url = getyoutubeVideolink( $embed_code ); echo $url; Now you can use this url in a iframe and where do you want

response.session.access_token is not working during the facebook connect?

JavaScript SDK and OAuth 2.0 Roadmap Facebook has updated JavaScript SDK and OAuth 2.0 Roadmap Due to this reason response.session.access_token is not working So You have make some changes in your Facebook login Function   FB.login(function(response) {                 if(response.session) {                     var access_token = response.session.access_token;                     FB.api('/me', function(response) {                     }                 } }   Your code was like this in facebook login function.   So edit some code and make this problem solved    FB.login(function(response) {                     if (response.authResponse) {                     var accessToken = response.authResponse.accessToken;                     alert(accessToken);                     FB.api('/me', function(response) {                     }                 } } So you have to change response.session to response.authResponse and  access_token to accessToken Done

How to print a response object comes by facebook login in javascript or jquery?

Facebook response return an object So for print the response You can use JSON . stringify () function. You can use this function as mention below alert( JSON . stringify (response)); Example : FB.login(function( response ) {                     FB.api('/me', function( response ) {                   var query = FB.Data.query('select src_big from photo where pid in (select cover_pid from album where owner={0} and name="Profile Pictures")', response.id);                  query.wait(function(rows) {                          alert(JSON.stringify(response));                                });                    }); }

How to add jquery vertical left panel slider?

Image
Many people says that they want a good left panel and they want that when they select any menu then submenu should be open in slow motion vertically. So here is the code of left panel slider with jquery and css with some screen shot. You can also edit them according to you need. On the first view left panel will look like this If you move your cursor on it than look like this If you click any option then it opens the submenu like this Here is the code simply copy and paste this code in your page and run // Code start from here <style> body {     font-family: Helvetica,Arial,sans-serif;     font-size: 0.9em; } p {     line-height: 1.5em; } ul#menu, ul#menu ul {     list-style-type: none;     margin: 0;     padding: 0;     width: 18em; } ul#menu a {     display: block;     text-decoration: none; } ul#menu li {     margin-top: 1px; } ul#menu li a {     background: none repeat scroll 0 0 #F5ECF5;     border: 1px solid #D7C2D7;

How to use facebook api for login Or register on our website?

<!--facebook login--> add latest jquery file on the top of the file <div id="fb-root"></div> <script type="text/javascript">             window.fbAsyncInit = function() {                 FB.init({appId: 'your api id', status: true, cookie: true, xfbml: true});                 /* All the events registered */                 FB.Event.subscribe('auth.login');                 FB.Event.subscribe('auth.logout');                               };                              (function() {                 var e = document.createElement('script');                 e.type = 'text/javascript';                 e.src = document.location.protocol +                     '//connect.facebook.net/en_US/all.js';                 e.async = true;                 document.getElementById('fb-root').appendChild(e);             }());                         function customFbLogin