toggle menu

Site move for 1 server to new developed server LEMP
Getting error 403 Forbidden nginx/1.14.0 (Ubuntu) apt

  • 0 like
  • 1 comment

Dhananjay Kumar19 May at 09:05

We have reviewed and seems file directory permission is changed and seems below Error:
"/var/www/domain.com/xyz.php" failed (13: Permission denied), client: xx.xxx.xx.xx

Finally used below command :
sudo chown -R www-data:www-data /var/www/*
sudo chmod -R 0755 /var/www/*
and restart nginx : sudo service nginx restart
and all working fine

Hi anyone's,

I want to implement 301 redirection  http both version, index.php and https non www version to https www version.

Please suggest me!!

Regards

Rajnish

  • 1 like
  • 2 comments

Dhananjay Kumar10 Jan at 05:01

Hi,

Please try the below script , its work on all :

For www only :

if ($_SERVER['HTTP_HOST']=='xyz.com') {
$url = "http://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

With HTTPS & WWW :

if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on" || $_SERVER['HTTP_HOST']=='domainname.com') {
$url = "https://www.". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

Try and suggest.

Dhananjay Kumar10 Jan at 05:01

Also, you may use this code

if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === "off") {
$url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
header( "HTTP/1.1 301 Moved Permanently" );
header("Location: {$url}");
exit;
}

Hello i want a solutions for categories off subcategories in array n level .

  • 1 like
  • 1 comment

Sanjana Kumari08 Sep at 12:09

<?php
$hostname = "localhost";
$db_username = "root";
$db_password = "";
$db_name = "test";

$db = new mysqli($hostname, $db_username, $db_password, $db_name);


class categoryss {

public function get_categories($id){
global $db;
$querycat='';
$gcategories=array();

if(is_null($id)){
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='0'";
}else{
$querycat = "SELECT cat_id,cat_name,parent_id FROM categories WHERE parent_id='".$id."'";
}

$result = $db->query($querycat);
if($result->num_rows>0){
while($row=$result->fetch_assoc()){
if(!empty($row['cat_id']) && $row!=''){
$gcategories[]=$row;
if(!empty($this->get_categories($row['cat_id']))){
$gcategories[]['child']=$this->get_categories($row['cat_id']);
}

}
}

}
return $gcategories;
}




////////////////////////////////////////
}

$obj=new categoryss();
$getNlevelCategory=$obj->get_categories('0');

/*echo "<pre>";
print_r($getNlevelCategory);*/
function traverseArray($array) {
if(is_array($array)){
foreach($array as $vals) {
echo @$vals['cat_name'] . "<br>";
traverseArray(@$vals['child']). "\n";
}
}
}
echo traverseArray($getNlevelCategory);
?>

Install CURL on PHP7.0 on LEMP server DigitalOcean?

Dhananjay Kumar |13 Aug at 11:08

Behave simply change below In command line and its working fine.

sudo apt-get install php7.0-curl

sudo systemctl restart php7.0-fpm

Please try.
Thanks

  • 1 like
  • 1 comment

Dhananjay Kumar04 Oct at 07:10

New updates come with :
sudo apt-get install php7.2-curl

Actually, you need to see what the version of PHP you installed here "/etc/php/"

nxn

Immwit work |12 Dec at 01:12

nxnx

  • 0 like
  • 0 comment

Hi all, 

I am new to PHP and my project's requirement is to store the data in database through form, submitted by end users, so i need to secure my code from XSS attacks and filter data. Can anyone guide me for the same. I am using Core PHP (OOP's) not any framework.

Thanks in advance :)

 

  • 1 like
  • 0 comment

FILTER_VALIDATE_EMAIL  function not working

See below mention example:

$email = "abc@domain.c";

if (filter_var($email, FILTER_VALIDATE_EMAIL))

        echo "Email: ".$email." correct";

else

        echo "email not correct"; 

 

//It returns:

Email: abc@domain.c correct //which is invalid email id

?>

 

Why FILTER_VALIDATE_EMAIL not work?

Because FILTER_VALIDATE_EMAIL not accepting Internationalized Domain Names and not allowed all characters according to RFC2822, so it might be better to use regex in php to validate email address instead of filter_validate_email.

 

Email validation in regex in php:

function valid_email($str) {

return (!preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;

}

 

if(!valid_email("abc@domain.c")){

echo "Invalid email address.";

}else{

echo "Valid email address.";

}?>

 

  • 1 like
  • 0 comment

My project's requirement is to integrate codeigniter and wordpress. Codeigniter files are in root directory of wordpress. Everything is working fine in wordpress but when i access the codeigniter pages it redirect me on wordpress's page not found page. My site is running on LEMP server. i searched regarding it on google , there were some solutions so i tried them but nothing worked in my case. Please help. I thank you in advance.

  • 1 like
  • 1 comment

Dhananjay Kumar26 May at 11:05

I was getting the same issues with LEMP server cause there, not .htaccess file working.
Due to this reason Codeigniter files path "https://abc.com/xyz/" is followed WordPress URL.
I have done the following below script in /etc/nginx/sites-enabled/default file:

location /xyz {
try_files $uri $uri/ /xyz/index.php?$args;
}
location /test {
try_files $uri $uri/ /test/index.php?$args;
}

Added above multiple "location" path which using in CodeIgniter. And its working fine for me.
Please once try above, hope you getting the solution.

Hi, I need help to integrate Paytm payment gateway on web and APP.

Can anyone here share step by step process with sample code to do the same.

I am using PHP as backend langauge.

thanks in advance.

 

  • 0 like
  • 0 comment

PHP is a single inheritance language ?

Mukund verma |23 Mar at 01:03

  • 0 like
  • 1 comment
  • 7 attempts

Govind Ramchander31 Mar at 07:03

Yes PHP is a single inheritance language

Single inheritance enables a derived class to inherit behavior and properties from a single parent class. It allows a derived class to inherit the properties and behavior of a base class, thus enabling code reusability as well as adding new features to the existing code. This makes the code much more elegant and less repetitive. Inheritance is one of the key features of object-oriented programming (OOP).

Single inheritance is safer than multiple inheritance if it is approached in the right way. It also enables a derived class to call the parent class implementation for a specific method if this method is overridden in the derived class or the parent class constructor.

demo image

Vibhu |18 Apr at 10:04

demo

  • 0 like
  • 1 comment

Chander Shekhar19 Apr at 05:04

lorem ispem dummy text

How to set cronjob on nginx server degitalocean?

Dhananjay Kumar |10 Apr at 05:04

I have setup cronjob on nginx server using below command :
$ crontab -e

and adding below script :
00 10 * * * /usr/bin/php /var/www/project_domain.com/index.php xyz_controller cronmethod

Above for the codeigniter function to run.

Not working any suggest.

  • 3 likes
  • 0 comment

demo

Vibhu |18 Apr at 10:04

demo

  • 2 likes
  • 0 comment

femo

Vibhu |18 Apr at 10:04

dko

  • 1 like
  • 0 comment

I am getting issues with the project live this Fatal error: Cannot use string offset as an array in /var/www/html/abc/xyz.php at line 40.

Same script working on my local server. I notice that's my local php version is 5.6 and live server version is  5.3.

Any have idea about this.

  • 0 like
  • 4 comments

vibhu09 Apr at 07:04

android.support.v7.widget.AppCompatEditText{3666be4 VFED..CL .F....I. 18,0-308,60

vibhu09 Apr at 08:04

fix this

vibhu09 Apr at 08:04

fix this

vibhu09 Apr at 08:04

how to fix

5ab36a0fcb77f.png

I am getting this error while integrating facebook login funcationality with php in my web.

please help.

  • 1 like
  • 1 comment

vibhu06 Apr at 01:04

android.support.v7.widget.AppCompatEditText{5199487 VFED..CL. .F....I. 24,0-478,80

I am newbie to PHP, can anyone explain me Getter and Setter methods in PHP, are they work similar like in JAVA or there is something different concept PHP use for these.

  • 1 like
  • 1 comment

Gaurav Thakur05 Apr at 10:04

Yes, Getter and setter methods works similar in PHP.
you can also use PHP's __get() & __set() methods.

Who is known as the father of PHP?

Gurnam Hiranandani |05 Apr at 09:04

  • 0 like
  • 0 comment
  • 4 attempts

Post share issue on Facebook

Govind Ramchander |15 Mar at 12:03

I am facing issues when sharing post on facebook. Facebook is randomly selecting images, title and descripton. I googled and tried some solutions but all those solutions did not work in my case. Those was working perfect for single post page but i have multiple posts listing on a single page. 

need help.

  • 1 like
  • 5 comments

Kaustubh Luthra28 Mar at 12:03

try this

<a href="https://www.facebook.com/sharer/sharer.php?u=example.org" target="_blank">
Share on Facebook
</a>

Replace the example.org with your post url.

paste this anchor tag where you want to display facebook share button
or if you have posts listed using loop then paste it within loop. I think it should work.

Govind Ramchander28 Mar at 12:03

Thanks Kaustubh Luthra but it didn't work for me. Random title, description, image are being posting using this solution.

Chetan Tushar28 Mar at 01:03

I am facing the same issue with my project. Anyone please help.

Sandeep Navaneet Saklani28 Mar at 01:03

I faced the same issue with a project of mine. After many days on debugging and searching found a solution which i am sharing with you.

function share_me(url, title) {
u=url;
t=title;
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),
'sharer',
'toolbar=0,status=0,width=500,height=450');

}

<a href="javascript:void(0);" onclick="share_me(url, title)" target="_blank">
Share on Facebook
</a>

Hope this will help.

Govind Ramchander31 Mar at 01:03

This solution is also not working. I am not getting what i am doing wrong.

Getting below error with site configure on new nginx server with php7.0

Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime()  

  • 0 like
  • 1 comment

Dhananjay Kumar01 Apr at 09:04

In php7 set_magic_quotes_runtime() & get_magic_quotes_runtime function is permanently removed and not work any setting for this, so please removed the used fucntion from your script.