Posts

Showing posts with the label php

convert 10 digit timestamp to readable format in mysql

SELECT * , UNIX_TIME ( submitdate ) You should use  UNIX_TIME () function in mysql to convert timestamp to readable form

How to find a string in current Url?

If u want to check a string in current url. So go through this note: strpos($_SERVER['REQUEST_URI']); example: if(strpos($_SERVER['REQUEST_URI'],"userprofile")!==false) { Echo “profile.php” } Where $_SERVER['REQUEST_URI'] use for get the current url

How to increase the time of execution or Fatal error: Maximum execution time of 60 seconds exceeded

Sometimes execution of my $command lasts too long and after 1min it stop execution and i receive this error: Copy and paste the at the top or of your file which file you are running; ini_set('max_execution_time', 0); Setting it to 0 will make your script run forever according to the documentation of the ini-directive .

How to setup a 301 Redirect in php

A 301 HTTP response status code is a way of telling search engines that a page, pages, directory or entire website has been permanently moved to another place on the web. This is very useful if you have changed the structure of your websites url’s or if you have moved domain. You can also redirect your entire site. Whereas a 301 code tells search engines that something has been permanently moved , a 302 code tells search engines that something has been temporarily moved . This is useful if you only want to redirect a page for a short period of time. To do a 302 redirect simply change the 301 part to 302. You can also use 303, which is means ’seeother’ and the page has been replaced by something else. Again, to do this simply substitute 301 with 303 in the tutorials below. How to setup a 301 Redirect The basic code for redirecting is : Redirect 301 old_location new_location   The old location of the file has to be the absolute path from the root of your server. The new

Get First date and last Last Date of current month in php.

// Get First date in current month in php. //echo $first_day = date('Y-m-d', strtotime(date('m').'/01/'.date('Y').' 00:00:00')); // Get Last date in current month in php. $last_day = date('Y-m-d',strtotime('-1 second',strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')))); echo $last_day;

Get First week day and last week day of current month in php.

// For First week day of current month echo $first_week_day = date("Y-m-d", strtotime(date("Y").'W'.date('W')."0")); // For Last week day of current month echo $last_week_day = date("Y-m-d", strtotime(date("Y").'W'.date('W')."7"));

make database connection in php

To make database connection in php make a new php file and copy that code there <?php $con = mysql_connect("hostname","username","password"); if (!$con)   {   die('Could not connect: ' . mysql_error());   } ?>